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>
HashSet
is an implementation ofSet
backed by aHashMap
.
-
-
Field Summary
Fields Modifier and Type Field Description private CompactHashMap<E,E>
compactHashMap
private static HashSet
EMPTY
private static KeyFunction
keyFunction
-
Constructor Summary
Constructors Modifier Constructor Description private
HashSet()
private
HashSet(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.boolean
contains(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> void
forEach(@NotNull Function<E,U> f)
All collection methods can be built upon thisforEach
definition.@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.int
size()
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:Set
Returns 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:Set
Removes the specified value from the set if it exists.
-
contains
public boolean contains(E value)
Description copied from interface:Set
Returns true if the value exists in this set.
-
size
public int size()
Description copied from interface:Traversable
Returns the size of the collection.Warning: infinite collections are possible, as are collections that require traversal to calculate the size.
- Specified by:
size
in interfaceTraversable<E>
- Overrides:
size
in classAbstractTraversable<E>
-
forEach
public <U> void forEach(@NotNull @NotNull Function<E,U> f)
Description copied from interface:Traversable
All collection methods can be built upon thisforEach
definition.- Specified by:
forEach
in interfaceTraversable<E>
- Overrides:
forEach
in classAbstractIterable<E>
-
iterator
@NotNull public @NotNull java.util.Iterator<E> iterator()
-
-