UnOrdered SET
-
hello this is Saad there is a Question revolving in my Mind that why a Set is UnOrdered ? ? :)
-
hello this is Saad there is a Question revolving in my Mind that why a Set is UnOrdered ? ? :)
by definition. sometimes an order is irrelevant to a collection, then use a set. It is like a mathematical set (remember Venn diagrams?). without any order, adding and removing items can be very fast operations. :)
Luc Pattyn [My Articles] Nil Volentibus Arduum
-
hello this is Saad there is a Question revolving in my Mind that why a Set is UnOrdered ? ? :)
as Luc says, it's so by definition. the Interface Set[^] is an extension to the interface Collection. And a Collection is unsorted - so it's most likely an inherited behavior.
regards Torsten When I'm not working
-
hello this is Saad there is a Question revolving in my Mind that why a Set is UnOrdered ? ? :)
As a guess, most collections do not need to be ordered. Thus ordering is something that is best done by adding it to a collection when needed. Also if collections started out ordered then attempting to make them unordered, for performance reasons, would probably be hard if possible at all. So better if everything started out unordered.
-
hello this is Saad there is a Question revolving in my Mind that why a Set is UnOrdered ? ? :)