Saturday 19 April 2014

TreeSet

TreeSet provides the basic operations like add, remove and contains in O(log n) time. Oracle implementation of TreeSet uses TreeMap in the TreeSet construction. TreeMap stores the elements in Reb Black tree model.

TreeSet is not synchronized. You can use Collections.synchronizedSortedSet to make use of synchronized set.

SortedSet s = Collections.synchronizedSortedSet(new TreeSet());

Above statement creates a synchronized set.


Prevoius                                                 Next                                                 Home

No comments:

Post a Comment