Package com.day.util
Class OrderedSet
java.lang.Object
com.day.util.OrderedSet
- All Implemented Interfaces:
Iterable,Collection,Set
Helper class that implements a set, but preserves the order of inserting
the elements when accessing an iterator.
- Since:
- coati, moved to com.day.util for iguana Audience core
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new, empty set; the backing HashMap instance has default initial capacity (16) and load factor (0.75).OrderedSet(int initialCapacity) Constructs a new, empty set; the backing Set instance has the specified initial capacity and default load factor, which is 0.75.OrderedSet(int initialCapacity, float loadFactor) Constructs a new, empty set; the backing Set instance has the specified initial capacity and the specified load factor.Constructs a new set containing the elements in the specified collection. -
Method Summary
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.Set
equals, hashCode, spliterator
-
Constructor Details
-
OrderedSet
public OrderedSet()Constructs a new, empty set; the backing HashMap instance has default initial capacity (16) and load factor (0.75). -
OrderedSet
Constructs a new set containing the elements in the specified collection. The Set is created with default load factor (0.75) and an initial capacity sufficient to contain the elements in the specified collection.- Parameters:
c- the collection whose elements are to be placed into this set.- Throws:
NullPointerException- if the specified collection is null.
-
OrderedSet
public OrderedSet(int initialCapacity, float loadFactor) Constructs a new, empty set; the backing Set instance has the specified initial capacity and the specified load factor.- Parameters:
initialCapacity- the initial capacity of the hash map.loadFactor- the load factor of the hash map.- Throws:
IllegalArgumentException- if the initial capacity is less than zero, or if the load factor is nonpositive.
-
OrderedSet
public OrderedSet(int initialCapacity) Constructs a new, empty set; the backing Set instance has the specified initial capacity and default load factor, which is 0.75.- Parameters:
initialCapacity- the initial capacity of the hash table.- Throws:
IllegalArgumentException- if the initial capacity is less than zero.
-
-
Method Details
-
size
public int size()- Specified by:
sizein interfaceCollection- Specified by:
sizein interfaceSet
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection- Specified by:
isEmptyin interfaceSet
-
contains
- Specified by:
containsin interfaceCollection- Specified by:
containsin interfaceSet
-
iterator
-
toArray
- Specified by:
toArrayin interfaceCollection- Specified by:
toArrayin interfaceSet
-
toArray
- Specified by:
toArrayin interfaceCollection- Specified by:
toArrayin interfaceSet
-
add
- Specified by:
addin interfaceCollection- Specified by:
addin interfaceSet
-
remove
- Specified by:
removein interfaceCollection- Specified by:
removein interfaceSet
-
containsAll
- Specified by:
containsAllin interfaceCollection- Specified by:
containsAllin interfaceSet
-
addAll
- Specified by:
addAllin interfaceCollection- Specified by:
addAllin interfaceSet
-
retainAll
- Specified by:
retainAllin interfaceCollection- Specified by:
retainAllin interfaceSet
-
removeAll
- Specified by:
removeAllin interfaceCollection- Specified by:
removeAllin interfaceSet
-
clear
public void clear()- Specified by:
clearin interfaceCollection- Specified by:
clearin interfaceSet
-