interface TableBase.Builder<R,C,V,Tp>
undocumented
Type parameters
| Name | Constraints | Default | Description |
|---|---|---|---|
| R | undocumented | ||
| C | undocumented | ||
| V | undocumented | ||
| Tp | TableBase.Types | TableBase.Types | undocumented |
Properties
amountRows
Returns the amount of rows in the builder.
amountRowsDefinition
readonly amountRows: number;
HashTableHashColumn.of([1, 2, 3], [1, 4, 5], [2, 3, 5])
.toBuilder()
.amountRows
// => 2
isEmpty
Returns true if there are no entries in the builder.
isEmptyDefinition
readonly isEmpty: boolean;
HashTableHashColumn.of([1, 2, 3], [1, 4, 5], [2, 3, 5])
.toBuilder()
.isEmpty
// => false
size
Returns the amount of entries in the builder.
sizeDefinition
readonly size: number;
HashTableHashColumn.of([1, 2, 3], [1, 4, 5], [2, 3, 5])
.toBuilder()
.size
// => 3
Methods
addEntries
Adds the given entries to the builder.
addEntriesentries to the builder.Definition
addEntries(entries: StreamSource<readonly [R, C, V]>): boolean;
Parameters
| Name | Type | Description |
|---|---|---|
entries | StreamSource<readonly [R, C, V]> |
const t = HashTableHashColumn.of([1, 2, 3], [1, 4, 5]).toBuilder()
t.addEntries([[1, 2, 3], [1, 2, 3]]) // => false
t.addEntries([[1, 2, 3], [2, 3, 4]]) // => true
addEntry
Adds the given entry to the builder.
addEntryentry to the builder.build
Returns an immutable collection instance containing the entries in this builder.
buildbuildMapValues
Returns an immutable collection instance containing the entries in this builder.
buildMapValuesDefinition
buildMapValues<V2>(mapFun: (value: V, row: R, column: C) => V2): (Tp & Row<R, C, V2>)['normal'];
Type parameters
| Name | Description |
|---|---|
| V2 |
Parameters
| Name | Type | Description |
|---|---|---|
mapFun | (value: V, row: R, column: C) => V2 | a function receiving the value, row and column, and returning a new value |
const m = HashTableHashColumn.of([1, 2, 3], [1, 4, 5]).toBuilder()
const m2: HashTableHashColumn<number, number, boolean> = m.buildMapValues(v => v > 3)
forEach
Performs given function f for each entry of the collection, using given state as initial traversal state.
forEachf for each entry of the collection, using given state as initial traversal state.Definition
forEach(f: (entry: [R, C, V], index: number, halt: () => void) => void, options?: {
state?: TraverseState;
}): void;
Parameters
| Name | Type | Description |
|---|---|---|
f | (entry: [R, C, V], index: number, halt: () => void) => void | the function to perform for each entry, receiving: - entry: the next tuple of a row key, column key, and value- index: the index of the element- halt: a function that, if called, ensures that no new elements are passed |
options | {state?: TraverseState;} | object containing the following - state: (optional) the traverse state |
HashTableHashColumn.of([1, 2, 3], [1, 4, 5], [2, 3, 5])
.toBuilder()
.forEach((entry, i, halt) => {
console.log([entry]);
if (i >= 1) halt();
})
// => logs [1, 2, 3] [1, 4, 5]
O(N)
get
Returns the value at given row and column keys, or the otherwise value if no value is present.
getrow and column keys, or the otherwise value if no value is present.Definitions
get<UR = R, UC = C>(row: RelatedTo<R, UR>, column: RelatedTo<C, UC>): V | undefined;
get<UR, UC, O>(row: RelatedTo<R, UR>, column: RelatedTo<C, UC>, otherwise: OptLazy<O>): V | O;
Type parameters
| Name | Default | Description |
|---|---|---|
| UR | R | |
| UC | C |
Parameters
| Name | Type | Description |
|---|---|---|
row | RelatedTo<R, UR> | the row key |
column | RelatedTo<C, UC> | the column key |
const t = HashTableHashColumn.of([1, 2, 3], [1, 4, 5]).toBuilder()
t.get(10, 1) // => undefined
t.get(10, 1, 0) // => 0
t.get(1, 2) // => 3
t.get(1, 2, 0) // => 3
getRow
Returns a map containing the column keys and values in the given row.
getRowrow.Definition
getRow<UR = R>(row: RelatedTo<R, UR>): WithRow<Tp, R, C, V>['row'];
Type parameters
| Name | Default | Description |
|---|---|---|
| UR | R |
Parameters
| Name | Type | Description |
|---|---|---|
row | RelatedTo<R, UR> | the row key |
const t = HashTableHashColumn.of([1, 2, 3], [1, 4, 5]).toBuilder()
t.getRow(10).toArray() // => []
t.getRow(1).toArray() // => [[2, 3], [4, 5]]
hasRowKey
Returns true if given row key is in the builder.
hasRowKeyrow key is in the builder.hasValueAt
Returns true if the builder has a value for given row and column keys.
hasValueAtrow and column keys.Definition
hasValueAt<UR = R, UC = C>(row: RelatedTo<R, UR>, column: RelatedTo<C, UC>): boolean;
Type parameters
| Name | Default | Description |
|---|---|---|
| UR | R | |
| UC | C |
Parameters
| Name | Type | Description |
|---|---|---|
row | RelatedTo<R, UR> | the row key |
column | RelatedTo<C, UC> | the column key |
const t = HashTableHashColumn.of([1, 2, 3], [1, 4, 5]).toBuilder()
t.hasValueAt(10, 1) // => false
t.hasValueAt(1, 4) // => true
modifyAt
Modifies the value at given row and column keys according to given options.
modifyAtrow and column keys according to given options.Definition
modifyAt(row: R, column: C, options: {
ifNew?: OptLazyOr<V, Token>;
ifExists?: (currentValue: V, remove: Token) => V |Token| V;
}): boolean;
Parameters
| Name | Type | Description |
|---|---|---|
row | R | the row key |
column | C | the column key |
options | {ifNew?: OptLazyOr<V, Token>;ifExists?: (currentValue: V, remove: Token) => V |Token| V;} |
const t = HashTableHashColumn.of([1, 2, 3], [1, 4, 5]).toBuilder()
t.modifyAt(2, 5, { ifNew: 8 })
// => true
t.modifyAt(2, 6, { ifNew: (none) => 1 < 2 ? none : 8 })
// => false
t.modifyAt(1, 2, { ifExists: (v) => v * 2 })
// => true
t.modifyAt(1, 2, { ifExists: (v, remove) => remove })
// => true
remove
Remove the value at given row and column keys in the builder.
removerow and column keys in the builder.Definitions
remove<UR = R, UC = C>(row: RelatedTo<R, UR>, column: RelatedTo<C, UC>): V | undefined;
remove<UR, UC, O>(row: RelatedTo<R, UR>, column: RelatedTo<C, UC>, otherwise: OptLazy<O>): V | O;
Type parameters
| Name | Default | Description |
|---|---|---|
| UR | R | |
| UC | C |
Parameters
| Name | Type | Description |
|---|---|---|
row | RelatedTo<R, UR> | the row key |
column | RelatedTo<C, UC> | the column key |
const t = HashTableHashColumn.of([1, 2, 3], [1, 4, 5]).toBuilder()
t.remove(5, 6) // => undefined
t.remove(5, 6, 'a') // => 'a'
t.remove(1, 2) // => 3
t.remove(1, 4, 'a') // => 5
removeEntries
Removes all given entries from the builder.
removeEntriesentries from the builder.Definition
removeEntries<UR = R, UC = C>(entries: StreamSource<[RelatedTo<R, UR>, RelatedTo<C, UC>]>): boolean;
Type parameters
| Name | Default | Description |
|---|---|---|
| UR | R | |
| UC | C |
Parameters
| Name | Type | Description |
|---|---|---|
entries | StreamSource<[RelatedTo<R, UR>, RelatedTo<C, UC>]> |
const t = HashTableHashColumn.of([1, 2, 3], [1, 4, 5], [2, 3, 5]).toBuilder()
t.removeEntries([[7, 8, 9], [9, 8, 7]]) // => false
t.removeEntries([[7, 8, 9], [1, 2, 3]]) // => true
removeRow
Removes all values in the given row from the builder.
removeRowrow from the builder.removeRows
Removes all given rows from the builder.
removeRowsrows from the builder.Definition
removeRows<UR = R>(rows: StreamSource<RelatedTo<R, UR>>): boolean;
Type parameters
| Name | Default | Description |
|---|---|---|
| UR | R |
Parameters
| Name | Type | Description |
|---|---|---|
rows | StreamSource<RelatedTo<R, UR>> |
const t = HashTableHashColumn.of([1, 2, 3], [1, 4, 5], [2, 3, 5]).toBuilder()
t.removeRows([10, 11]) // => false
t.removeRows([1, 10]) // => true
set
Sets the given value for the given row and column keys in the builder.
setvalue for the given row and column keys in the builder.updateAt
Updates the value at given row and column keys according to the given update function.
updateAtrow and column keys according to the given update function.Definitions
updateAt(row: R, column: C, update: Update<V>): V | undefined;
updateAt<O>(row: R, column: C, update: Update<V>, otherwise: OptLazy<O>): V | O;
Parameters
| Name | Type | Description |
|---|---|---|
row | R | the row key |
column | C | the column key |
update | Update<V> | a function taking the current value and returning a new value |
const t = HashTableHashColumn.of([1, 2, 3], [1, 4, 5])
t.updateAt(3, 4, v => v * 2) // => undefined
t.updateAt(3, 4, v => v * 2, 'a') // => 'a'
t.updateAt(1, 2, v => v * 2) // => true
t.updateAt(1, 2, v => v * 2, 'a') // => true