Please enable JavaScript.
Coggle requires JavaScript to display documents.
Set Interface, NavigableSet - Coggle Diagram
Set Interface
HashSet
Stores its elements in a
Hash Table
It uses the int
hashCode
() method to retrieve objects.
Adding an element and checking if element exists in the set takes
constant time
You loose the order of which you inserted the elements.
Can contain at most one
null
value
TreeSet
Stores its elements in a
Tree
Elements of the set are are always in sorted order
Adding and checking if an element exists takes
O(log n)
TreeSet implements the
NavigableSet
interface
If you try to insert null, you got a null pointer exception because of the sorting.
Set
Doesn't allow duplicate values
Can have at most one null element
NavigableSet
Used by
TreeSet
E
floor
(E e)
E
ceiling
(E e)
E
lower
(E e)
E
higher
(E e)