Package com.day.util
Class OrderedSet
- java.lang.Object
-
- com.day.util.OrderedSet
-
- All Implemented Interfaces:
Iterable,Collection,Set
public class OrderedSet extends Object implements 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
Constructors Constructor Description OrderedSet()Constructs 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.OrderedSet(Collection c)Constructs a new set containing the elements in the specified collection.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(Object o)booleanaddAll(Collection c)voidclear()booleancontains(Object o)booleancontainsAll(Collection c)booleanisEmpty()Iteratoriterator()booleanremove(Object o)booleanremoveAll(Collection c)booleanretainAll(Collection c)intsize()Object[]toArray()Object[]toArray(Object[] a)-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.Set
equals, hashCode, spliterator
-
-
-
-
Constructor Detail
-
OrderedSet
public OrderedSet()
Constructs a new, empty set; the backing HashMap instance has default initial capacity (16) and load factor (0.75).
-
OrderedSet
public OrderedSet(Collection c)
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 Detail
-
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
public boolean contains(Object o)
- Specified by:
containsin interfaceCollection- Specified by:
containsin interfaceSet
-
iterator
public Iterator iterator()
-
toArray
public Object[] toArray()
- Specified by:
toArrayin interfaceCollection- Specified by:
toArrayin interfaceSet
-
toArray
public Object[] toArray(Object[] a)
- Specified by:
toArrayin interfaceCollection- Specified by:
toArrayin interfaceSet
-
add
public boolean add(Object o)
- Specified by:
addin interfaceCollection- Specified by:
addin interfaceSet
-
remove
public boolean remove(Object o)
- Specified by:
removein interfaceCollection- Specified by:
removein interfaceSet
-
containsAll
public boolean containsAll(Collection c)
- Specified by:
containsAllin interfaceCollection- Specified by:
containsAllin interfaceSet
-
addAll
public boolean addAll(Collection c)
- Specified by:
addAllin interfaceCollection- Specified by:
addAllin interfaceSet
-
retainAll
public boolean retainAll(Collection c)
- Specified by:
retainAllin interfaceCollection- Specified by:
retainAllin interfaceSet
-
removeAll
public boolean removeAll(Collection c)
- Specified by:
removeAllin interfaceCollection- Specified by:
removeAllin interfaceSet
-
clear
public void clear()
- Specified by:
clearin interfaceCollection- Specified by:
clearin interfaceSet
-
-