Borislav Mirchev wrote:. . .
'For convenience, "ordering" will here refer to the order of items returned by an Iterator, and "sorting" will here refer to sorting items according to Comparable or Comparator.'
. . .
That quote isn't quite accurate. And that SO thread shows how much confusion there is about ordering.
All collections have an order, which is how their element are returned from an Iterator. What are commonly called ordered collections are those where the iteration order is related to the insertion order. Lists, most Queues, and Stacks behave like that, but some of them are ordered backwards. It is also often possible to alter the iteration order; a List can be sorted or shuffled, for example.
Some collections iterate their elements in order of some feature of those elements (getting larger or getting smaller) and those are usually called sorted. A tree set automatically sorts its elements as they are inserted.
Some collections can be iterated without the order being easily predictable. A hash set returns its elements in some sort of order to do with their hash codes, and that order might change if the collection becomes larger. These are often called unordered, but that term isn't accurate.
https://www.selikoff.net/ocp11-2/ it is the book errata page. The issue I've found is not mentioned there. The documentation says the iterator() method returns the elements in ascending order, not in the order of insertion. And if I'm properly understanding the terminology ConcurrentSkipListSet is not an ordered collection as mentioned in the TABLE 7.9.
The exact text that can be put in Errata is:
Chapter 7, in Table 7.9 for ConcurrentSkipListSet in the column: Elements ordered? is written Yes.
It should be:
Chapter 7, in Table 7.9 for ConcurrentSkipListSet in the column: Element ordered? the correct value is No.
or something similar.
It is in case an ordered collection is meant that where iterator() returns the elements in order of addition.
In case iterator() returns the element in any possible order or order of insertion for CopyOnWriteArraySet in Java 11 doc is written: "Returns an iterator over the elements contained in this set in the order in which these elements were added."
while in the table in the column: Element ordered? is written "No" while it should be "Yes".
Probably this table needs an additional review and/or explanation of the Element ordered?'s meaning.
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop