Package org.javimmutable.collections
Interface ISet<T>
- All Superinterfaces:
ICollection<T>
,InvariantCheckable
,IStreamable<T>
,Iterable<T>
,Mapped<T,
,T> Serializable
,SplitableIterable<T>
- All Known Subinterfaces:
IMultiset<T>
- All Known Implementing Classes:
AbstractMultiset
,AbstractSet
,AbstractSetUsingMap
,EmptyHashSet
,HashMultiset
,HashSet
,OrderedMultiset
,OrderedSet
,TreeMultiset
,TreeSet
@Immutable
public interface ISet<T>
extends ICollection<T>, Mapped<T,T>, InvariantCheckable, Serializable
Interface for immutable sets.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Determines if the Set contains the specified value.boolean
containsAll
(Iterable<? extends T> values) Determines if the Set contains all values in the specified collection.boolean
containsAll
(Iterator<? extends T> values) Determines if the Set contains all values in the specified collection.boolean
containsAny
(Iterable<? extends T> values) Determines if the Set contains any values in the specified collection.boolean
containsAny
(Iterator<? extends T> values) Determines if the Set contains any values in the specified collection.Removes the value from the Set.Removes all values of other from the Set.Removes all values of other from the Set.Returns a Holder containing the specified key if its contained in the set.default T
Returns the specified key if its contained in the set.getSet()
default T
getValueOr
(T key, T defaultValue) Returns the specified key if its contained in the set.Adds the single value to the Set.Adds all of the elements of the specified collection to the set.Adds all of the elements of the specified collection to the set.intersection
(Iterable<? extends T> other) Removes all values from the Set that are not contained in the other collection.intersection
(Iterator<? extends T> values) Removes all values from the Set that are not contained in the other collection.intersection
(Set<? extends T> other) Removes all values from the Set that are not contained in the other collection.intersection
(ISet<? extends T> other) Removes all values from the Set that are not contained in the other collection.Returns a set of the same type as this containing all those elements for which predicate returns false.Returns a set of the same type as this containing only those elements for which predicate returns true.Returns a Collector that creates a set of the same type as this containing all of the collected values inserted over whatever starting values this already contained.Adds all values from other to the Set.Adds all values from other to the Set.Methods inherited from interface org.javimmutable.collections.ICollection
isEmpty, isNonEmpty, size
Methods inherited from interface org.javimmutable.collections.InvariantCheckable
checkInvariants
Methods inherited from interface org.javimmutable.collections.IStreamable
getSpliteratorCharacteristics, iterator, parallelStream, spliterator, stream
Methods inherited from interface org.javimmutable.collections.SplitableIterable
forEachThrows, indexedForEach, indexedForEachThrows, reduce, reduceThrows
-
Method Details
-
insert
Adds the single value to the Set.- Specified by:
insert
in interfaceICollection<T>
- Returns:
- instance of set containing the value
-
insertAll
Adds all of the elements of the specified collection to the set.- Specified by:
insertAll
in interfaceICollection<T>
- Returns:
- instance of set containing the collection
-
insertAll
Adds all of the elements of the specified collection to the set.- Specified by:
insertAll
in interfaceICollection<T>
- Returns:
- instance of set containing the collection
-
contains
Determines if the Set contains the specified value.- Returns:
- true if the Set contains the value
-
containsAll
Determines if the Set contains all values in the specified collection.- Returns:
- true if the Set contains the values
-
containsAll
Determines if the Set contains all values in the specified collection.- Returns:
- true if the Set contains the values
-
containsAny
Determines if the Set contains any values in the specified collection.- Returns:
- true if the Set contains a value
-
containsAny
Determines if the Set contains any values in the specified collection.- Returns:
- true if the Set contains a value
-
delete
Removes the value from the Set. Has no effect if the value is not in the Set.- Returns:
- instance of set without the value
-
deleteAll
Removes all values of other from the Set. Has no effect if none of the values are in the Set- Returns:
- instance of set without the values
-
deleteAll
Removes all values of other from the Set. Has no effect if none of the values are in the Set- Returns:
- instance of set without the values
-
union
Adds all values from other to the Set.- Parameters:
other
- source of values to add- Returns:
- instance of set containing the values
-
union
Adds all values from other to the Set.- Parameters:
values
- source of values to add- Returns:
- instance of set containing the values
-
intersection
Removes all values from the Set that are not contained in the other collection.- Returns:
- instance of set with unmatched values removed
-
intersection
Removes all values from the Set that are not contained in the other collection.- Returns:
- instance of set with unmatched values removed
-
intersection
Removes all values from the Set that are not contained in the other collection.- Returns:
- instance of set with unmatched values removed
-
intersection
Removes all values from the Set that are not contained in the other collection.- Returns:
- instance of set with unmatched values removed
-
deleteAll
- Specified by:
deleteAll
in interfaceICollection<T>
- Returns:
- an equivalent collection with no values
-
getSet
- Returns:
- an unmodifiable Set implementation backed by this set.
-
get
Returns the specified key if its contained in the set. Otherwise returns null. -
getValueOr
Returns the specified key if its contained in the set. Otherwise returns defaultValue.- Specified by:
getValueOr
in interfaceMapped<T,
T> - Parameters:
key
- identifies the value to retrievedefaultValue
- value to return if no entry exists for key- Returns:
- the key or defaultValue
-
find
Returns a Holder containing the specified key if its contained in the set. Otherwise returns an empty Holder. -
select
Returns a set of the same type as this containing only those elements for which predicate returns true. Implementations are optimized assuming predicate will return false more often than true.- Parameters:
predicate
- decides whether to include an element- Returns:
- set of same type as this containing only those elements for which predicate returns true
-
reject
Returns a set of the same type as this containing all those elements for which predicate returns false. Implementations are optimized assuming predicate will return false more often than true.- Parameters:
predicate
- decides whether to include an element- Returns:
- set of same type as this containing only those elements for which predicate returns false
-
setCollector
Returns a Collector that creates a set of the same type as this containing all of the collected values inserted over whatever starting values this already contained.
-