Class HashSet<E>
- java.lang.Object
-
- com.github.andrewoma.dexx.collection.internal.base.AbstractTraversable<E>
-
- com.github.andrewoma.dexx.collection.internal.base.AbstractIterable<E>
-
- com.github.andrewoma.dexx.collection.internal.base.AbstractSet<E>
-
- com.github.andrewoma.dexx.collection.HashSet<E>
-
- All Implemented Interfaces:
Iterable<E>,Set<E>,Traversable<E>,java.lang.Iterable<E>
public class HashSet<E> extends AbstractSet<E>
HashSetis an implementation ofSetbacked by aHashMap.
-
-
Field Summary
Fields Modifier and Type Field Description private CompactHashMap<E,E>compactHashMapprivate static HashSetEMPTYprivate static KeyFunctionkeyFunction
-
Constructor Summary
Constructors Modifier Constructor Description privateHashSet()privateHashSet(CompactHashMap<E,E> compactHashMap)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull HashSet<E>add(E value)Returns a set that adds the specified value if it doesn't already exist in this set.booleancontains(E value)Returns true if the value exists in this set.static <E> @NotNull HashSet<E>empty()static <E> @NotNull BuilderFactory<E,HashSet<E>>factory()<U> voidforEach(@NotNull Function<E,U> f)All collection methods can be built upon thisforEachdefinition.@NotNull java.util.Iterator<E>iterator()private KeyFunction<E,E>keyFunction()@NotNull HashSet<E>remove(E value)Removes the specified value from the set if it exists.intsize()Returns the size of the collection.-
Methods inherited from class com.github.andrewoma.dexx.collection.internal.base.AbstractSet
asSet, equals, hashCode
-
Methods inherited from class com.github.andrewoma.dexx.collection.internal.base.AbstractTraversable
isEmpty, makeString, makeString, to, toArray, toArray, toIndexedList, toSet, toSortedSet, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.github.andrewoma.dexx.collection.Traversable
isEmpty, makeString, makeString, to, toArray, toArray, toIndexedList, toSet, toSortedSet
-
-
-
-
Field Detail
-
EMPTY
private static final HashSet EMPTY
-
keyFunction
private static final KeyFunction keyFunction
-
compactHashMap
private final CompactHashMap<E,E> compactHashMap
-
-
Constructor Detail
-
HashSet
private HashSet()
-
HashSet
private HashSet(CompactHashMap<E,E> compactHashMap)
-
-
Method Detail
-
factory
@NotNull public static <E> @NotNull BuilderFactory<E,HashSet<E>> factory()
-
empty
@NotNull public static <E> @NotNull HashSet<E> empty()
-
keyFunction
private KeyFunction<E,E> keyFunction()
-
add
@NotNull public @NotNull HashSet<E> add(E value)
Description copied from interface:SetReturns a set that adds the specified value if it doesn't already exist in this set.
-
remove
@NotNull public @NotNull HashSet<E> remove(E value)
Description copied from interface:SetRemoves the specified value from the set if it exists.
-
contains
public boolean contains(E value)
Description copied from interface:SetReturns true if the value exists in this set.
-
size
public int size()
Description copied from interface:TraversableReturns the size of the collection.Warning: infinite collections are possible, as are collections that require traversal to calculate the size.
- Specified by:
sizein interfaceTraversable<E>- Overrides:
sizein classAbstractTraversable<E>
-
forEach
public <U> void forEach(@NotNull @NotNull Function<E,U> f)Description copied from interface:TraversableAll collection methods can be built upon thisforEachdefinition.- Specified by:
forEachin interfaceTraversable<E>- Overrides:
forEachin classAbstractIterable<E>
-
iterator
@NotNull public @NotNull java.util.Iterator<E> iterator()
-
-