Class ArrayKeySet<E extends Key>
- java.lang.Object
-
- org.pepstock.charba.client.commons.ArrayKeySet<E>
-
- All Implemented Interfaces:
Iterable<E>
,Collection<E>
,Set<E>
public final class ArrayKeySet<E extends Key> extends Object
A collection that contains no duplicate elements.
More formally, sets contain no pair of elementse1
ande2
such thate1.equals(e2)
, and at most one null element.
This implementation uses a java script object as back-end to store objects (Key
values).
Some methods are annotated with@SuppressWarnings("unusable-by-js")
because J2CL transpiler emits warnings as not usable in the javascript part but this collection must not be passed to any javascript code.- Author:
- Andrea "Stock" Stocchero
-
-
Constructor Summary
Constructors Constructor Description ArrayKeySet(KeyFactory<E> factory)
Creates an empty set.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(E e)
Adds the specified element to this set if it is not already present (optional operation).boolean
addAll(Collection<? extends E> c)
Appends all of the elements in the specified collection to the end of this set, in the order that they are returned by the specified collection's iteratorvoid
clear()
Removes all of the elements from this set.boolean
contains(Object object)
Returns true if this set contains the specified element.boolean
containsAll(Collection<?> c)
Returns true if this set contains all of the elements of the specified collection.boolean
isEmpty()
Returns true if this set contains no elementsIterator<E>
iterator()
Returns an iterator over the elements in this set.boolean
remove(Object o)
Removes the first occurrence of the specified element from this set, if it is present.boolean
removeAll(Collection<?> c)
Removes from this set all of its elements that are contained in the specified collection.boolean
retainAll(Collection<?> c)
Retains only the elements in this set that are contained in the specified collection.
In other words, removes from this set all of its elements that are not contained in the specified collection.int
size()
Returns the number of elements in this set.Object[]
toArray()
Returns an array containing all of the elements in this set.<T> T[]
toArray(T[] a)
Returns an array containing all of the elements in this set; the runtime type of the returned array is that of the specified array.String
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, 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
-
ArrayKeySet
public ArrayKeySet(KeyFactory<E> factory)
Creates an empty set.- Parameters:
factory
- factory instance to create the key from a native one.
-
-
Method Detail
-
add
public boolean add(E e)
Adds the specified element to this set if it is not already present (optional operation).
-
size
public final int size()
Returns the number of elements in this set.- Specified by:
size
in interfaceCollection<E>
- Specified by:
size
in interfaceSet<E>
-
isEmpty
public final boolean isEmpty()
Returns true if this set contains no elements- Specified by:
isEmpty
in interfaceCollection<E>
- Specified by:
isEmpty
in interfaceSet<E>
-
contains
public final boolean contains(Object object)
Returns true if this set contains the specified element.- Specified by:
contains
in interfaceCollection<E>
- Specified by:
contains
in interfaceSet<E>
-
iterator
public final Iterator<E> iterator()
Returns an iterator over the elements in this set.
-
toArray
public final Object[] toArray()
Returns an array containing all of the elements in this set.- Specified by:
toArray
in interfaceCollection<E>
- Specified by:
toArray
in interfaceSet<E>
-
toArray
public final <T> T[] toArray(T[] a)
Returns an array containing all of the elements in this set; the runtime type of the returned array is that of the specified array.- Specified by:
toArray
in interfaceCollection<E>
- Specified by:
toArray
in interfaceSet<E>
-
remove
public final boolean remove(Object o)
Removes the first occurrence of the specified element from this set, if it is present. If this set does not contain the element, it is unchanged.- Specified by:
remove
in interfaceCollection<E>
- Specified by:
remove
in interfaceSet<E>
-
containsAll
public final boolean containsAll(Collection<?> c)
Returns true if this set contains all of the elements of the specified collection.- Specified by:
containsAll
in interfaceCollection<E>
- Specified by:
containsAll
in interfaceSet<E>
-
addAll
public final boolean addAll(Collection<? extends E> c)
Appends all of the elements in the specified collection to the end of this set, in the order that they are returned by the specified collection's iterator- Specified by:
addAll
in interfaceCollection<E>
- Specified by:
addAll
in interfaceSet<E>
-
retainAll
public final boolean retainAll(Collection<?> c)
Retains only the elements in this set that are contained in the specified collection.
In other words, removes from this set all of its elements that are not contained in the specified collection.- Specified by:
retainAll
in interfaceCollection<E>
- Specified by:
retainAll
in interfaceSet<E>
-
removeAll
public final boolean removeAll(Collection<?> c)
Removes from this set all of its elements that are contained in the specified collection.- Specified by:
removeAll
in interfaceCollection<E>
- Specified by:
removeAll
in interfaceSet<E>
-
clear
public final void clear()
Removes all of the elements from this set. The set will be empty after this call returns.- Specified by:
clear
in interfaceCollection<E>
- Specified by:
clear
in interfaceSet<E>
-
-