New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Either documentation or implementation of PriorityQueue.iterator (and dependent functions) is incorrect #5085

Closed
scabug opened this Issue Oct 18, 2011 · 2 comments

Comments

Projects
None yet
2 participants
@scabug
Copy link

scabug commented Oct 18, 2011

The source code and documentation of scala.collections.mutable.PriorityQueue states that for .iterator and various dependent functions (notably .toList and .toString) elements are returned in priority order, which is not what the implementation actually does. Other methods, in particular the critical methods .dequeue() and .dequeueAll() behave correctly.

To reproduce:

     @Test def test() {
        val pq = new scala.collections.mutable.PriorityQueue[Int]()
        pq ++= List( 9,1,8,2,7,3 )
        println( pq.iterator.mkString(",") ) // = "9,7,8,1,2,3"
     }

Origin: came up via http://stackoverflow.com/questions/7792189/scala-what-is-the-most-appropriate-data-structure-for-sorted-subsets/7792837#7792837

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Oct 18, 2011

Imported From: https://issues.scala-lang.org/browse/SI-5085?orig=1
Reporter: Gregor Scheidt (gregor)
Affected Versions: 2.9.0-1

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Oct 18, 2011

@axel22 said (edited on Oct 18, 2011 7:37:19 AM UTC):
The documentation is not up-to-date. Priority queue iterators don't respect any order.

@scabug scabug closed this Jan 8, 2013

@scabug scabug added the docs label Apr 7, 2017

@scabug scabug added this to the 2.10.0-M3 milestone Apr 7, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment