interface HashSet.NonEmpty<T>
A non-empty type-invariant immutable Set of value type T. In the Set, there are no duplicate values. See the Set documentation and the HashSet API documentation
Extends: Streamable.NonEmpty<T>
, RSetBase.NonEmpty<T,Tp>
, HashSet<T>
Implemented by: HashSetNonEmptyBase<T>
Type parameters
Name | Description |
---|---|
T | the value type |
- The
HashSet
uses the context'shasher
instance to hash keys for performance. - TheHashSet
uses the context'seq
function to determine equivalence between keys.
const s1 = HashSet.empty<string>()
const s2 = HashSet.of('a', 'b', 'c')
Properties
context
Returns the context
associated to this collection instance.
context
context
associated to this collection instance.isEmpty
Returns false since this collection is known to be non-empty
isEmpty
size
Returns the number of values in the collection.
size
Methods
[Symbol.iterator]
Returns a FastIterator
instance used to iterate over the values of this Iterable
.
[Symbol.iterator]
FastIterator
instance used to iterate over the values of this Iterable
.add
Returns the collection with given value
added.
add
value
added.addAll
Returns the collection with the values in given values
StreamSource
added.
addAll
values
StreamSource
added.asNormal
Returns this collection typed as a 'possibly empty' collection.
asNormal
assumeNonEmpty
Returns a self reference since this collection is known to be non-empty.
assumeNonEmpty
difference
Returns a collection where each value of given other
StreamSource
is removed from this collection.
difference
other
StreamSource
is removed from this collection.filter
Returns a collection containing only those entries that satisfy given pred
predicate.
filter
pred
predicate.forEach
Performs given function f
for each value of the collection, using given state
as initial traversal state.
forEach
f
for each value of the collection, using given state
as initial traversal state.has
Returns true if given value
is in the collection.
has
value
is in the collection.intersect
Returns a collection containing values that are both in this collection, and in the given other
StreamSource
.
intersect
other
StreamSource
.nonEmpty
Returns true since this collection is know to be non-empty
nonEmpty
remove
Returns the collection with given value
removed.
remove
value
removed.removeAll
Returns the collection with all values in the given values
StreamSource
removed.
removeAll
values
StreamSource
removed.stream
Returns a non-empty Stream
of the elements in this collection.
stream
Stream
of the elements in this collection.symDifference
Returns a collection of the values that are either in this collection or in the other
StreamSource
, but not in both.
symDifference
other
StreamSource
, but not in both.toArray
Returns a non-empty array containing all values in this collection.
toArray
toBuilder
Returns a builder object containing the values of this collection.
toBuilder
toJSON
Returns a JSON representation of this collection.
toJSON
toString
Returns a string representation of this collection.
toString
union
Returns a collection containing all values from this collection and all values of given other
StreamSource
.
union
other
StreamSource
.