Package org.organicdesign.fp.collections
Class PersistentHashSet.MutableHashSet<E>
- java.lang.Object
-
- org.organicdesign.fp.collections.AbstractUnmodIterable<T>
-
- org.organicdesign.fp.collections.AbstractUnmodSet<E>
-
- org.organicdesign.fp.collections.PersistentHashSet.MutableHashSet<E>
-
- All Implemented Interfaces:
java.lang.Iterable<E>,java.util.Collection<E>,java.util.Set<E>,BaseSet<E>,MutableSet<E>,Sized,UnmodCollection<E>,UnmodIterable<E>,UnmodSet<E>,Transformable<E>
- Enclosing class:
- PersistentHashSet<E>
public static final class PersistentHashSet.MutableHashSet<E> extends AbstractUnmodSet<E> implements MutableSet<E>
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(java.lang.Object key)Returns true if the set contains the given item.PersistentHashSet<E>immutable()Returns an immutable version of this immutable set.UnmodIterator<E>iterator()Iterates over contents with no guarantees about their ordering.PersistentHashSet.MutableHashSet<E>put(E val)Adds an element.intsize()Returns the number of items in this collection or iterable.PersistentHashSet.MutableHashSet<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 org.organicdesign.fp.collections.MutableSet
union
-
Methods inherited from interface org.organicdesign.fp.xform.Transformable
toImList, toImMap, toImRrbt, toImSet, toImSortedMap, toImSortedSet, toMutableList, toMutableMap, toMutableRrbt, toMutableSet, toMutableSortedMap, toMutableSortedSet
-
-
-
-
Method Detail
-
size
public int size()
Description copied from interface:SizedReturns the number of items in this collection or iterable.
-
put
public PersistentHashSet.MutableHashSet<E> put(E val)
Description copied from interface:MutableSetAdds 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
public 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.- Specified by:
iteratorin interfacejava.util.Collection<E>- Specified by:
iteratorin interfacejava.lang.Iterable<E>- Specified by:
iteratorin interfacejava.util.Set<E>- Specified by:
iteratorin interfaceUnmodCollection<E>- Specified by:
iteratorin interfaceUnmodIterable<E>- Specified by:
iteratorin interfaceUnmodSet<E>
-
contains
public boolean contains(java.lang.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
public PersistentHashSet.MutableHashSet<E> without(E key)
Description copied from interface:MutableSetRemoves this key from the set
-
immutable
public PersistentHashSet<E> immutable()
Description copied from interface:MutableSetReturns an immutable version of this immutable set.- Specified by:
immutablein interfaceMutableSet<E>
-
-