E - Set element.public class GridBoundedLinkedHashSet<E> extends GridSerializableSet<E> implements Cloneable
Set interface,
with predictable iteration order. This implementation differs from
HashSet in that it maintains a doubly-linked list running through
all of its entries. This linked list defines the iteration ordering,
which is the order in which elements were inserted into the set
(insertion-order). Note that insertion order is not affected
if an element is re-inserted into the set. (An element e
is reinserted into a set s if s.add(e) is invoked when
s.contains(e) would return true immediately prior to
the invocation.)
HashSet is also has maximum capacity. When it is reached the newest elements supersede eldest ones.
| Constructor and Description |
|---|
GridBoundedLinkedHashSet(Collection<? extends E> c,
int maxCap)
Constructs a new set containing the elements in the specified collection.
|
GridBoundedLinkedHashSet(int maxCap)
Constructs a new, empty set; the backing
LinkedHashMap
instance has default initial capacity (16) and load factor (0.75). |
GridBoundedLinkedHashSet(int initCap,
int maxCap)
Constructs a new, empty set; the backing
LinkedHashHashMap
instance has the specified initial capacity and default load factor, which
is 0.75. |
GridBoundedLinkedHashSet(int initCap,
int maxCap,
float loadFactor)
Constructs a new, empty set; the backing
LinkedHashMap
instance has the specified initial capacity and the specified load factor. |
GridBoundedLinkedHashSet(int initCap,
int maxCap,
float loadFactor,
boolean accessOrder)
Constructs a new, empty set; the backing
LinkedHashMap
instance has the specified initial capacity and the specified load factor. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E o)
Adds the specified element to this set if it is not already present.
|
void |
clear()
Removes all of the elements from this set.
|
Object |
clone()
Returns a shallow copy of this
GridBoundedLinkedHashSet
instance: the elements themselves are not cloned. |
boolean |
contains(Object o)
Returns
true if this set contains the specified element. |
boolean |
isEmpty()
Returns
true if this set contains no elements. |
Iterator<E> |
iterator()
Returns an iterator over the elements in this set.
|
boolean |
remove(Object o)
Removes the specified element from this set if it is present.
|
int |
size()
Returns the number of elements in this set (its cardinality).
|
equals, hashCode, removeAlladdAll, containsAll, retainAll, toArray, toArray, toStringfinalize, getClass, notify, notifyAll, wait, wait, waitaddAll, containsAll, retainAll, spliterator, toArray, toArrayparallelStream, removeIf, streampublic GridBoundedLinkedHashSet(int maxCap)
LinkedHashMap
instance has default initial capacity (16) and load factor (0.75).maxCap - Maximum set capacity.public GridBoundedLinkedHashSet(Collection<? extends E> c, int maxCap)
LinkedHashMap is created with default load factor (0.75)
and an initial capacity sufficient to contain the elements in the specified
collection.c - The collection whose elements are to be placed into this set.maxCap - Maximum set capacity.public GridBoundedLinkedHashSet(int initCap,
int maxCap,
float loadFactor)
LinkedHashMap
instance has the specified initial capacity and the specified load factor.initCap - The initial capacity of the hash map.maxCap - Maximum set capacity.loadFactor - the Load factor of the hash map.public GridBoundedLinkedHashSet(int initCap,
int maxCap,
float loadFactor,
boolean accessOrder)
LinkedHashMap
instance has the specified initial capacity and the specified load factor.initCap - The initial capacity of the hash map.maxCap - Maximum set capacity.loadFactor - the Load factor of the hash map.accessOrder - True for access order, false for insertion order.public GridBoundedLinkedHashSet(int initCap,
int maxCap)
LinkedHashHashMap
instance has the specified initial capacity and default load factor, which
is 0.75.initCap - The initial capacity of the hash table.maxCap - Maximum capacity.public Iterator<E> iterator()
iterator in interface Iterable<E>iterator in interface Collection<E>iterator in interface Set<E>iterator in class AbstractCollection<E>ConcurrentModificationExceptionpublic int size()
size in interface Collection<E>size in interface Set<E>size in class AbstractCollection<E>public boolean isEmpty()
true if this set contains no elements.isEmpty in interface Collection<E>isEmpty in interface Set<E>isEmpty in class AbstractCollection<E>True if this set contains no elements.public boolean contains(Object o)
true if this set contains the specified element.contains in interface Collection<E>contains in interface Set<E>contains in class AbstractCollection<E>o - Element whose presence in this set is to be tested.true if this set contains the specified element.public boolean add(E o)
add in interface Collection<E>add in interface Set<E>add in class AbstractCollection<E>o - Element to be added to this set.True if the set did not already contain the specified
element.public boolean remove(Object o)
remove in interface Collection<E>remove in interface Set<E>remove in class AbstractCollection<E>o - Object to be removed from this set, if present.True if the set contained the specified element.public void clear()
clear in interface Collection<E>clear in interface Set<E>clear in class AbstractCollection<E>public Object clone() throws CloneNotSupportedException
GridBoundedLinkedHashSet
instance: the elements themselves are not cloned.clone in class ObjectCloneNotSupportedException - Thrown if cloning is not supported.
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.7.5 Release Date : June 4 2019