class MultiSetBuilder<T,Tp,TpG>
undocumented
Implements: MultiSetBase.Builder<T,Tp>
Type parameters
Name | Constraints | Default | Description |
---|---|---|---|
T | undocumented | ||
Tp | ContextImplTypes | undocumented | |
TpG | WithElem <Tp, T> | WithElem <Tp, T> | undocumented |
Properties
_countMap
undocumented
_countMap
Definition
_countMap?:
RMap.Builder
<T, number>;
addAll
undocumented
addAll
Definition
addAll: (source:
StreamSource
<T>) => boolean;
addEntries
undocumented
addEntries
Definition
addEntries: (entries:
StreamSource
<readonly [T, number]>) => boolean;
countMap
undocumented
countMap
Definition
get countMap():
RMap.Builder
<T, number>;
forEach
undocumented
forEach
Definition
forEach: (f: (value: T, index: number, halt: () => void) => void, options?: {
state?:
TraverseState
;
}) => void;
isEmpty
undocumented
isEmpty
modifyCount
undocumented
modifyCount
Definition
modifyCount: (value: T, update: (currentCount: number) => number) => boolean;
remove
undocumented
remove
removeAll
undocumented
removeAll
Definition
removeAll: <U>(values:
StreamSource
<
RelatedTo
<T, U>>, mode: "SINGLE"
|
"ALL") => boolean;
removeAllEvery
undocumented
removeAllEvery
Definition
removeAllEvery: <U>(values:
StreamSource
<
RelatedTo
<T, U>>) => boolean;
removeAllSingle
undocumented
removeAllSingle
Definition
removeAllSingle: <U>(values:
StreamSource
<
RelatedTo
<T, U>>) => boolean;
size
undocumented
size
sizeDistinct
undocumented
sizeDistinct
Methods
add
Adds given value
to the builder.
add
value
to the builder.addAll
Adds the values in given values
StreamSource
to the builder.
addAll
values
StreamSource
to the builder.Definition
addAll(values:
StreamSource
<T>): boolean;
Parameters
Name | Type | Description |
---|---|---|
values | StreamSource <T> |
const s = HashMultiSet.of(1, 2, 2).toBuilder()
s.addAll(1, 3) // => false
s.addAll(2, 10) // => true
Overrides
addEntries
Adds for each tuple of a value and amount in the given entries
, the amount of values to the builder.
addEntries
entries
, the amount of values to the builder.Definition
addEntries(entries:
StreamSource
<readonly [T, number]>): boolean;
Parameters
Name | Type | Description |
---|---|---|
entries | StreamSource <readonly [T, number]> |
const s = HashMultiSet.of(1, 2, 2).toBuilder()
s.addEntries([[1, 2], [2, 3]]) // => true
s.addEntries([[1, 0], [3, 0]]) // => false
Overrides
build
Returns an immutable instance containing the values in this builder.
build
count
Returns the amount of given value
in the builder.
count
value
in the builder.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.Definition
forEach(f: (value: T, index: number, halt: () => void) => void, options?: {
state?:
TraverseState
;
}): void;
Parameters
Name | Type | Description |
---|---|---|
f | (value: T, index: number, halt: () => void) => void | the function to perform for each value, receiving: - value : the next value- index : the index of the value- halt : a function that, if called, ensures that no new values are passed |
options | { state?: TraverseState ; } | (optional) an object containing the following properties: - state: (optional) the traversal state |
RibuError.ModifiedBuilderWhileLoopingOverItError if the builder is modified while looping over it
HashMultiSet.of(1, 2, 2, 3).toBuilder().forEach((entry, i, halt) => {
console.log(entry)
if (i >= 1) halt()
})
// => logs [1, 1] [2, 2]
Overrides
has
Returns true if the given value
is present in the builder.
has
value
is present in the builder.modifyCount
Changes the amount of given value
in the builder according to the result of given update
function.
modifyCount
value
in the builder according to the result of given update
function.Definition
modifyCount(value: T, update: (currentCount: number) => number): boolean;
Parameters
Name | Type | Description |
---|---|---|
value | T | the value of which to update the amount |
update | (currentCount: number) => number |
if the given value
does not exists, the update
function is called with 0. @note if the result of update
is <= 0, the value will be removed (or not added)
const s = HashMultiSet.of(1, 2, 2).toBuilder()
s.modifyCount(3, v => v) // => false
s.modifyCount(3, v => v + 1) // => true
s.modifyCount(2, v => v + 1) // => true
Overrides
remove
Removes given amount
or all of given value
from the builder.
remove
amount
or all of given value
from the builder.Definition
remove<U = T>(value:
RelatedTo
<T, U>, amount?: number
|
'ALL'): number;
Type parameters
Name | Default | Description |
---|---|---|
U | T |
Parameters
Name | Type | Description |
---|---|---|
value | RelatedTo <T, U> | the value to remove |
amount | number | 'ALL' |
const s = HashMultiSet.of(1, 2, 2).toBuilder()
s.remove(10) // => 0
s.remove(1, 2) // => 1
s.remove(2, 2) // => 2
Overrides
removeAllEvery
Removes every instance of the given values
from the builder.
removeAllEvery
values
from the builder.Definition
removeAllEvery<U = T>(values:
StreamSource
<
RelatedTo
<T, U>>): boolean;
Type parameters
Name | Default | Description |
---|---|---|
U | T |
Parameters
Name | Type | Description |
---|---|---|
values | StreamSource < RelatedTo <T, U>> |
const s = HashMultiSet.of(1, 2, 2).toBuilder()
s.removeAllEvery([10, 11]) // => false
s.removeAllEvery([1, 11]) // => true
Overrides
removeAllSingle
Removes every single value in given values
from the builder.
removeAllSingle
values
from the builder.Definition
removeAllSingle<U = T>(values:
StreamSource
<
RelatedTo
<T, U>>): boolean;
Type parameters
Name | Default | Description |
---|---|---|
U | T |
Parameters
Name | Type | Description |
---|---|---|
values | StreamSource < RelatedTo <T, U>> |
const s = HashMultiSet.of(1, 2, 2).toBuilder()
s.removeAllSingle([10, 11]) // => false
s.removeAllSingle([1, 11]) // => true
Overrides
setCount
Sets the amount of given value
in the collection to amount
.
setCount
value
in the collection to amount
.Definition
setCount(value: T, amount: number): boolean;
Parameters
Name | Type | Description |
---|---|---|
value | T | the value for which to set the amount |
amount | number |
if amount <= 0, the value will be removed
const s = HashMultiSet.of(1, 2, 2).toBuilder()
s.setCount(1, 1) // => false
s.setCount(1, 3) // => true