Class HashSet<T>
java.lang.Object
org.javimmutable.collections.common.AbstractSet<T>
org.javimmutable.collections.hash.HashSet<T>
- All Implemented Interfaces:
Serializable,Iterable<T>,ArrayAssignMapper<T,,T, ArraySetNode<T>> ArrayContainsMapper<T,,ArraySetNode<T>> ArrayDeleteMapper<T,,ArraySetNode<T>> ArrayIterationMapper<T,,T, ArraySetNode<T>> ArraySizeMapper<ArraySetNode<T>>,ICollection<T>,InvariantCheckable,ISet<T>,IStreamable<T>,Mapped<T,,T> SplitableIterable<T>
@Immutable
public class HashSet<T>
extends AbstractSet<T>
implements ArrayAssignMapper<T,T,ArraySetNode<T>>, ArrayContainsMapper<T,ArraySetNode<T>>, ArrayIterationMapper<T,T,ArraySetNode<T>>, ArrayDeleteMapper<T,ArraySetNode<T>>, Serializable
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> ISetBuilder<T> builder()voidChecks invariants of implementing class.booleanDetermines if the Set contains the specified value.Removes the value from the Set.Removes all values of other from the Set.Implemented by derived classes to create a new empty Setvoid<E extends Exception>
voidforEachThrows(Proc1Throws<T, E> proc) Processes every value using the provided function.intAdds the single value to the Set.intersection(Iterator<? extends T> values) Removes all values from the Set that are not contained in the other collection.intersection(Set<? extends T> otherSet) Removes all values from the Set that are not contained in the other collection.booleanisEmpty()iterator()Overridden here to require implementations to return a SplitableIterator rather than a basic Iterator.mappedAssign(ArraySetNode<T> current, T key, T ignored) Called during assign operation to replace an existing mapping for the given key and value.mappedAssign(T key, T ignored) Called during assign operation to create a new mapping for the given key and value.booleanmappedContains(ArraySetNode<T> mapping, T key) mappedDelete(ArraySetNode<T> current, T key) Called during delete operation to delete a key from a mapping.mappedEntries(ArraySetNode<T> mapping) mappedKeys(ArraySetNode<T> mapping) intmappedSize(ArraySetNode<T> mapping) Called to obtain number of keys in a given mapping.mappedValues(ArraySetNode<T> mapping) static <T> ISet<T> of()intsize()Adds all values from other to the Set.Methods inherited from class org.javimmutable.collections.common.AbstractSet
containsAll, containsAll, containsAny, containsAny, deleteAll, equals, getSet, hashCode, insertAll, insertAll, intersection, intersection, toString, unionMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.javimmutable.collections.ICollection
isNonEmptyMethods inherited from interface org.javimmutable.collections.ISet
find, get, getValueOr, reject, select, setCollectorMethods inherited from interface org.javimmutable.collections.IStreamable
parallelStream, spliterator, streamMethods inherited from interface org.javimmutable.collections.SplitableIterable
indexedForEach, indexedForEachThrows, reduce, reduceThrows
-
Method Details
-
of
-
builder
-
deleteAll
-
emptyMutableSet
Description copied from class:AbstractSetImplemented by derived classes to create a new empty Set- Specified by:
emptyMutableSetin classAbstractSet<T>
-
insert
Description copied from interface:ISetAdds the single value to the Set. -
contains
Description copied from interface:ISetDetermines if the Set contains the specified value. -
delete
Description copied from interface:ISetRemoves the value from the Set. Has no effect if the value is not in the Set. -
deleteAll
Description copied from interface:ISetRemoves all values of other from the Set. Has no effect if none of the values are in the Set -
union
Description copied from interface:ISetAdds all values from other to the Set. -
intersection
Description copied from interface:ISetRemoves all values from the Set that are not contained in the other collection.- Specified by:
intersectionin interfaceISet<T>- Returns:
- instance of set with unmatched values removed
-
intersection
Description copied from interface:ISetRemoves all values from the Set that are not contained in the other collection.- Specified by:
intersectionin interfaceISet<T>- Returns:
- instance of set with unmatched values removed
-
size
public int size()- Specified by:
sizein interfaceICollection<T>- Returns:
- number of values in the collection
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceICollection<T>- Returns:
- true only if collection contains no values
-
checkInvariants
public void checkInvariants()Description copied from interface:InvariantCheckableChecks invariants of implementing class.- Specified by:
checkInvariantsin interfaceInvariantCheckable
-
forEach
-
forEachThrows
Description copied from interface:SplitableIterableProcesses every value using the provided function.- Specified by:
forEachThrowsin interfaceSplitableIterable<T>- Throws:
E
-
iterator
Description copied from interface:IStreamableOverridden here to require implementations to return a SplitableIterator rather than a basic Iterator. This is necessary to allow composition of new objects from methods like keys() and values().- Specified by:
iteratorin interfaceIStreamable<T>- Specified by:
iteratorin interfaceIterable<T>- Specified by:
iteratorin interfaceSplitableIterable<T>
-
getSpliteratorCharacteristics
public int getSpliteratorCharacteristics()- Specified by:
getSpliteratorCharacteristicsin interfaceIStreamable<T>- Returns:
- characteristics value used when creating Spliterators
-
mappedContains
- Specified by:
mappedContainsin interfaceArrayContainsMapper<T,ArraySetNode<T>>
-
mappedAssign
Description copied from interface:ArrayAssignMapperCalled during assign operation to create a new mapping for the given key and value.- Specified by:
mappedAssignin interfaceArrayAssignMapper<T,T, ArraySetNode<T>> - Parameters:
key- key being assigned toignored- value being assigned- Returns:
- non-null mapping
-
mappedAssign
@Nonnull public ArraySetNode<T> mappedAssign(@Nonnull ArraySetNode<T> current, @Nonnull T key, T ignored) Description copied from interface:ArrayAssignMapperCalled during assign operation to replace an existing mapping for the given key and value.- Specified by:
mappedAssignin interfaceArrayAssignMapper<T,T, ArraySetNode<T>> - Parameters:
current- mapping to be replacedkey- key being assigned toignored- value being assigned- Returns:
- same to keep mapping or non-null to replace mapping
-
mappedDelete
Description copied from interface:ArrayDeleteMapperCalled during delete operation to delete a key from a mapping.- Specified by:
mappedDeletein interfaceArrayDeleteMapper<T,ArraySetNode<T>> - Parameters:
current- mapping to be replacedkey- key being deleted- Returns:
- null to remove mapping, same to keep mapping, or non-null to replace mapping
-
mappedSize
Description copied from interface:ArraySizeMapperCalled to obtain number of keys in a given mapping.- Specified by:
mappedSizein interfaceArraySizeMapper<T>- Parameters:
mapping- mapping to be sized- Returns:
- number of keys in the mapping
-
mappedKeys
- Specified by:
mappedKeysin interfaceArrayIterationMapper<T,T, ArraySetNode<T>>
-
mappedValues
- Specified by:
mappedValuesin interfaceArrayIterationMapper<T,T, ArraySetNode<T>>
-
mappedEntries
@Nonnull public GenericIterator.Iterable<IMapEntry<T,T>> mappedEntries(@Nonnull ArraySetNode<T> mapping) - Specified by:
mappedEntriesin interfaceArrayIterationMapper<T,T, ArraySetNode<T>>
-