org.apache.ignite.internal.util

## Class GridBoundedLinkedHashSet<E>

- java.lang.Object
- - java.util.AbstractCollection<E>
  - - java.util.AbstractSet<E>
    - - org.apache.ignite.internal.util.GridSerializableSet<E>
      - - org.apache.ignite.internal.util.GridBoundedLinkedHashSet<E>

Type Parameters:
  `E` - Set element.

All Implemented Interfaces:
  Serializable, Cloneable, Iterable<E>, Collection<E>, Set<E>

    public class GridBoundedLinkedHashSet<E>
    extends GridSerializableSet<E>
    implements Cloneable

Hash table and linked list implementation of the `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.

See Also:
  Serialized Form

### Constructor Summary

Constructors
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.

### Method Summary

Methods
`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).

### Methods inherited from class java.util.AbstractSet

`equals, hashCode, removeAll`

### Methods inherited from class java.util.AbstractCollection

`addAll, containsAll, retainAll, toArray, toArray, toString`

### Methods inherited from class java.lang.Object

`finalize, getClass, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface java.util.Set

`addAll, containsAll, retainAll, toArray, toArray`

### Constructor Detail

#### GridBoundedLinkedHashSet

    public GridBoundedLinkedHashSet(int maxCap)

Constructs a new, empty set; the backing `LinkedHashMap` instance has default initial capacity (16) and load factor (0.75).

Parameters:
  `maxCap` - Maximum set capacity.

#### GridBoundedLinkedHashSet

    public GridBoundedLinkedHashSet(Collection<? extends E> c,
                            int maxCap)

Constructs a new set containing the elements in the specified collection. The `LinkedHashMap` 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.
  `maxCap` - Maximum set capacity.

#### GridBoundedLinkedHashSet

    public 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.

Parameters:
  `initCap` - The initial capacity of the hash map.
  `maxCap` - Maximum set capacity.
  `loadFactor` - the Load factor of the hash map.

#### GridBoundedLinkedHashSet

    public 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.

Parameters:
  `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.

#### GridBoundedLinkedHashSet

    public 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`.

Parameters:
  `initCap` - The initial capacity of the hash table.
  `maxCap` - Maximum capacity.

### Method Detail

#### iterator

    public Iterator<E> iterator()

Returns an iterator over the elements in this set. The elements are returned in no particular order.

Specified by:
  `iterator` in interface `Iterable<E>`
Specified by:
  `iterator` in interface `Collection<E>`
Specified by:
  `iterator` in interface `Set<E>`
Specified by:
  `iterator` in class `AbstractCollection<E>`
Returns:
  An iterator over the elements in this set.
See Also:
  `ConcurrentModificationException`

#### size

    public int size()

Returns the number of elements in this set (its cardinality).

Specified by:
  `size` in interface `Collection<E>`
Specified by:
  `size` in interface `Set<E>`
Specified by:
  `size` in class `AbstractCollection<E>`
Returns:
  The number of elements in this set (its cardinality).

#### isEmpty

    public boolean isEmpty()

Returns `true` if this set contains no elements.

Specified by:
  `isEmpty` in interface `Collection<E>`
Specified by:
  `isEmpty` in interface `Set<E>`
Overrides:
  `isEmpty` in class `AbstractCollection<E>`
Returns:
  `True` if this set contains no elements.

#### contains

    public boolean contains(Object o)

Returns `true` if this set contains the specified element.

Specified by:
  `contains` in interface `Collection<E>`
Specified by:
  `contains` in interface `Set<E>`
Overrides:
  `contains` in class `AbstractCollection<E>`
Parameters:
  `o` - Element whose presence in this set is to be tested.
Returns:
  `true` if this set contains the specified element.

#### add

    public boolean add(E o)

Adds the specified element to this set if it is not already present.

Specified by:
  `add` in interface `Collection<E>`
Specified by:
  `add` in interface `Set<E>`
Overrides:
  `add` in class `AbstractCollection<E>`
Parameters:
  `o` - Element to be added to this set.
Returns:
  `True` if the set did not already contain the specified element.

#### remove

    public boolean remove(Object o)

Removes the specified element from this set if it is present.

Specified by:
  `remove` in interface `Collection<E>`
Specified by:
  `remove` in interface `Set<E>`
Overrides:
  `remove` in class `AbstractCollection<E>`
Parameters:
  `o` - Object to be removed from this set, if present.
Returns:
  `True` if the set contained the specified element.

#### clear

    public void clear()

Removes all of the elements from this set.

Specified by:
  `clear` in interface `Collection<E>`
Specified by:
  `clear` in interface `Set<E>`
Overrides:
  `clear` in class `AbstractCollection<E>`

#### clone

    public Object clone()
                 throws CloneNotSupportedException

Returns a shallow copy of this `GridBoundedLinkedHashSet` instance: the elements themselves are not cloned.

Overrides:
  `clone` in class `Object`
Returns:
  a shallow copy of this set.
Throws:
  `CloneNotSupportedException` - Thrown if cloning is not supported.

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.0.0-RC3
Release Date | : March 24 2015