Thursday 1 May 2014

LinkedHashSet

LinkedHashSet is intermediate between HashSet and TreeSet. Implemented as a hash table with a linked list running through it, however it provides insertion-ordered iteration which is not same as sorted traversal guaranteed by TreeSet.

Like HashSet, it provides constant-time performance for the basic operations add, contains and remove.

Like HashSet, LinkedHashSet permits null Elements.

LinkedHashSet is not synchronized. To create Synchronized LinkedHashSet use the below statement.

Set s = Collections.synchronizedSet(new LinkedHashSet());

LinkedHashSet provides four constructors.

It provides the same methods like HashSet.


public class LinkedHashSet<E> extends HashSet<E> implements Set<E>{
 public LinkedHashSet(int initialCapacity, float loadFactor);
 public LinkedHashSet(int initialCapacity);
 public LinkedHashSet();
 public LinkedHashSet(Collection<? extends E> c);
}


Prevoius                                                 Next                                                 Home

No comments:

Post a Comment