Package org.organicdesign.fp.collections
Class PersistentHashSet.MutHashSet<E>
- java.lang.Object
-
- org.organicdesign.fp.collections.AbstractUnmodIterable<T>
-
- org.organicdesign.fp.collections.AbstractUnmodSet<E>
-
- org.organicdesign.fp.collections.PersistentHashSet.MutHashSet<E>
-
- All Implemented Interfaces:
Iterable<E>,Collection<E>,Set<E>,BaseSet<E>,MutSet<E>,Sized,UnmodCollection<E>,UnmodIterable<E>,UnmodSet<E>,Transformable<E>
- Enclosing class:
- PersistentHashSet<E>
public static final class PersistentHashSet.MutHashSet<E> extends AbstractUnmodSet<E> implements MutSet<E>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.organicdesign.fp.collections.UnmodIterable
UnmodIterable.UnIterable
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(Object key)Returns true if the set contains the given item.@NotNull PersistentHashSet<E>immutable()Returns an immutable version of this immutable set.@NotNull UnmodIterator<E>iterator()Iterates over contents with no guarantees about their ordering.@NotNull PersistentHashSet.MutHashSet<E>put(E val)Adds an element.intsize()Returns the number of items in this collection or iterable.@NotNull PersistentHashSet.MutHashSet<E>without(E key)Removes this key from the set-
Methods inherited from class org.organicdesign.fp.collections.AbstractUnmodSet
equals
-
Methods inherited from class org.organicdesign.fp.collections.AbstractUnmodIterable
hashCode, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
-
Methods inherited from interface java.util.Set
equals, hashCode, spliterator
-
Methods inherited from interface org.organicdesign.fp.xform.Transformable
any, toImList, toImMap, toImRrbt, toImSet, toImSortedMap, toImSortedSet, toMutList, toMutMap, toMutRrbt, toMutSet, toMutSortedMap, toMutSortedSet
-
-
-
-
Method Detail
-
size
public int size()
Description copied from interface:SizedReturns the number of items in this collection or iterable.
-
put
@NotNull public @NotNull PersistentHashSet.MutHashSet<E> put(E val)
Description copied from interface:MutSetAdds an element. If the element already exists in this set, the new value overwrites the old one. If the new element is the same as an old element (based on the address of that item in memory, not an equals test), the old set may be returned unchanged.
-
iterator
@NotNull public @NotNull UnmodIterator<E> iterator()
Description copied from interface:UnmodSetIterates over contents with no guarantees about their ordering. An unmodifiable iterator A one-time use, mutable, not-thread-safe way to get each value of the underling collection in turn. I experimented with various thread-safe alternatives, but the JVM is optimized around iterators so this is the lowest common denominator of collection iteration, even though iterators are inherently mutable.
-
contains
public boolean contains(Object key)
Description copied from interface:UnmodSetReturns true if the set contains the given item. This is the defining method of a set. Sets have to override this because the default implementation in UnmodCollection is O(n) whereas a sorted set should be O(log n) or O(1).
-
without
@NotNull public @NotNull PersistentHashSet.MutHashSet<E> without(E key)
Description copied from interface:MutSetRemoves this key from the set
-
-