Class ArrayStringSet
- java.lang.Object
-
- org.pepstock.charba.client.commons.ArrayStringSet
-
public final class ArrayStringSet extends Object
A collection that contains no duplicate elements.
More formally, sets contain no pair of elementse1ande2such thate1.equals(e2), and at most one null element.
This implementation uses a java script object as back-end to store objects (string 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 ArrayStringSet()Creates an empty set.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(String e)Adds the specified element to this set if it is not already present (optional operation).booleanaddAll(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 iteratorvoidclear()Removes all of the elements from this set.booleancontains(Object object)Returns true if this set contains the specified element.booleancontainsAll(Collection<?> c)Returns true if this set contains all of the elements of the specified collection.booleanisEmpty()Returns true if this set contains no elementsIterator<E>iterator()Returns an iterator over the elements in this set.booleanremove(Object o)Removes the first occurrence of the specified element from this set, if it is present.booleanremoveAll(Collection<?> c)Removes from this set all of its elements that are contained in the specified collection.booleanretainAll(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.intsize()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.StringtoString()-
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
-
-
-
-
Method Detail
-
add
public boolean add(String 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:
sizein interfaceCollection<E>- Specified by:
sizein interfaceSet<E>
-
isEmpty
public final boolean isEmpty()
Returns true if this set contains no elements- Specified by:
isEmptyin interfaceCollection<E>- Specified by:
isEmptyin interfaceSet<E>
-
contains
public final boolean contains(Object object)
Returns true if this set contains the specified element.- Specified by:
containsin interfaceCollection<E>- Specified by:
containsin 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:
toArrayin interfaceCollection<E>- Specified by:
toArrayin 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:
toArrayin interfaceCollection<E>- Specified by:
toArrayin 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:
removein interfaceCollection<E>- Specified by:
removein 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:
containsAllin interfaceCollection<E>- Specified by:
containsAllin 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:
addAllin interfaceCollection<E>- Specified by:
addAllin 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:
retainAllin interfaceCollection<E>- Specified by:
retainAllin 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:
removeAllin interfaceCollection<E>- Specified by:
removeAllin 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:
clearin interfaceCollection<E>- Specified by:
clearin interfaceSet<E>
-
-