{"action":"reopened","issue":{"url":"https://api.github.com/repos/dart-lang/collection/issues/45","repository_url":"https://api.github.com/repos/dart-lang/collection","labels_url":"https://api.github.com/repos/dart-lang/collection/issues/45/labels{/name}","comments_url":"https://api.github.com/repos/dart-lang/collection/issues/45/comments","events_url":"https://api.github.com/repos/dart-lang/collection/issues/45/events","html_url":"https://github.com/dart-lang/collection/issues/45","id":196684280,"number":45,"title":"PriorityQueue and comparison function inconsistent","user":{"login":"floitschG","id":8631949,"avatar_url":"https://avatars2.githubusercontent.com/u/8631949?v=4","gravatar_id":"","url":"https://api.github.com/users/floitschG","html_url":"https://github.com/floitschG","followers_url":"https://api.github.com/users/floitschG/followers","following_url":"https://api.github.com/users/floitschG/following{/other_user}","gists_url":"https://api.github.com/users/floitschG/gists{/gist_id}","starred_url":"https://api.github.com/users/floitschG/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/floitschG/subscriptions","organizations_url":"https://api.github.com/users/floitschG/orgs","repos_url":"https://api.github.com/users/floitschG/repos","events_url":"https://api.github.com/users/floitschG/events{/privacy}","received_events_url":"https://api.github.com/users/floitschG/received_events","type":"User","site_admin":false},"labels":[{"id":180327798,"url":"https://api.github.com/repos/dart-lang/collection/labels/bug","name":"bug","color":"fc2929","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-12-20T14:21:32Z","updated_at":"2018-03-15T18:54:08Z","closed_at":null,"author_association":"MEMBER","body":"The documentat of `PriorityQueue` states:\r\n```\r\n  /// The [comparison] is a [Comparator] used to compare the priority of\r\n  /// elements. An element that compares as less than another element has\r\n  /// a higher priority.\r\n```\r\n\r\n(btw: the documentation doesn't state what the function should return).\r\n\r\nHowever, the comparison function is also used as equality function.\r\nFor example, `PriorityQueue.contains`, or `PriorityQueue.remove` both use this function to determine equality. In some cases that works, but a common use case is to extract a priority field from one of many fields.\r\n\r\nExample:\r\n``` dart\r\nclass PriorityPoint {\r\n  int x, y, priority;\r\n  PriorityPoint(this.x, this.y, this.priority);\r\n}\r\n\r\nvar queue = new PriorityQueue(comparison: (p1, p2) => p2.priority - p1.priority);\r\nqueue.add(new PriorityPoint(0, 1, 5));\r\nqueue.contains(new PriorityPoint(-1, -3, 5));  // Should probably return false.\r\n```\r\n\r\nI'm not sure what the best solution is, but the current behavior and documentation are not consistent.\r\nFurthermore, the current behavior makes it hard to implement the provided use case."}}
{"actor":{"display_login":"nex3"}}