Skip to main content

interface TableBase.Builder<R,C,V,Tp>

undocumented

Implemented by: Table.Builder<R,C,V>, HashTableSortedColumn.Builder<R,C,V>, SortedTableHashColumn.Builder<R,C,V>, SortedTableSortedColumn.Builder<R,C,V>, HashTableHashColumn.Builder<R,C,V>

Type parameters

NameConstraintsDefaultDescription
Rundocumented
Cundocumented
Vundocumented
TpTableBase.TypesTableBase.Typesundocumented

Properties

amountRows

Returns the amount of rows in the builder.

Definition

readonly amountRows: number;

example
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.

Definition

readonly isEmpty: boolean;

example
HashTableHashColumn.of([1, 2, 3], [1, 4, 5], [2, 3, 5])
.toBuilder()
.isEmpty
// => false

size

Returns the amount of entries in the builder.

Definition

readonly size: number;

example
HashTableHashColumn.of([1, 2, 3], [1, 4, 5], [2, 3, 5])
.toBuilder()
.size
// => 3

Methods

addEntries

Adds the given entries to the builder.

Definition

addEntries(entries: StreamSource<readonly [R, C, V]>): boolean;

Parameters

NameTypeDescription
entriesStreamSource<readonly [R, C, V]>
example
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.

Definition

addEntry(entry: readonly [R, C, V]): boolean;

Parameters

NameTypeDescription
entryreadonly [R, C, V]
example
const t = HashTableHashColumn.of([1, 2, 3], [1, 4, 5]).toBuilder()
t.addEntry([1, 2, 3]) // => false
t.addEntry([1, 3, 8]) // => true

build

Returns an immutable collection instance containing the entries in this builder.

Definition

build(): WithRow<Tp, R, C, V>['normal'];

example
const m = HashTableHashColumn.of([1, 2, 3], [1, 4, 5]).toBuilder()
const m2: HashTableHashColumn<number, number, number> = m.build()

buildMapValues

Returns an immutable collection instance containing the entries in this builder.

Definition

buildMapValues<V2>(mapFun: (value: V, row: R, column: C) => V2): (Tp & Row<R, C, V2>)['normal'];

Type parameters

NameDescription
V2

Parameters

NameTypeDescription
mapFun(value: V, row: R, column: C) => V2a function receiving the value, row and column, and returning a new value
example
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.

Definition

forEach(f: (entry: [R, C, V], index: number, halt: () => void) => void, options?: {
      state?: TraverseState;
    }): void;

Parameters

NameTypeDescription
f(entry: [R, C, V], index: number, halt: () => void) => voidthe 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
example
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]
note

O(N)

get

Returns the value at given row 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

NameDefaultDescription
URR
UCC

Parameters

NameTypeDescription
rowRelatedTo<R, UR>the row key
columnRelatedTo<C, UC>the column key
example
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.

Definition

getRow<UR = R>(row: RelatedTo<R, UR>): WithRow<Tp, R, C, V>['row'];

Type parameters

NameDefaultDescription
URR

Parameters

NameTypeDescription
rowRelatedTo<R, UR>the row key
example
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.

Definition

hasRowKey<UR = R>(row: RelatedTo<R, UR>): boolean;

Type parameters

NameDefaultDescription
URR

Parameters

NameTypeDescription
rowRelatedTo<R, UR>the row key to look for
example
const t = HashTableHashColumn.of([1, 2, 3], [1, 4, 5]).toBuilder()
t.hasRowKey(10) // => false
t.hasRowKey(1) // => true

hasValueAt

Returns true if the builder has a value for given row and column keys.

Definition

hasValueAt<UR = R, UC = C>(row: RelatedTo<R, UR>, column: RelatedTo<C, UC>): boolean;

Type parameters

NameDefaultDescription
URR
UCC

Parameters

NameTypeDescription
rowRelatedTo<R, UR>the row key
columnRelatedTo<C, UC>the column key
example
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.

Definition

modifyAt(row: R, column: C, options: {
      ifNew?: OptLazyOr<V, Token>;
      ifExists?: (currentValue: V, remove: Token) => V |Token| V;
    }): boolean;

Parameters

NameTypeDescription
rowRthe row key
columnCthe column key
options{
      ifNew?: OptLazyOr<V, Token>;
      ifExists?: (currentValue: V, remove: Token) => V |Token| V;
    }
example
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.

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

NameDefaultDescription
URR
UCC

Parameters

NameTypeDescription
rowRelatedTo<R, UR>the row key
columnRelatedTo<C, UC>the column key
example
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.

Definition

removeEntries<UR = R, UC = C>(entries: StreamSource<[RelatedTo<R, UR>, RelatedTo<C, UC>]>): boolean;

Type parameters

NameDefaultDescription
URR
UCC

Parameters

NameTypeDescription
entriesStreamSource<[RelatedTo<R, UR>, RelatedTo<C, UC>]>
example
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.

Definition

removeRow<UR = R>(row: RelatedTo<R, UR>): boolean;

Type parameters

NameDefaultDescription
URR

Parameters

NameTypeDescription
rowRelatedTo<R, UR>
example
const t = HashTableHashColumn.of([1, 2, 3], [1, 4, 5], [2, 3, 5]).toBuilder()
t.removeRow(5) // => false
t.removeRow(1) // => true

removeRows

Removes all given rows from the builder.

Definition

removeRows<UR = R>(rows: StreamSource<RelatedTo<R, UR>>): boolean;

Type parameters

NameDefaultDescription
URR

Parameters

NameTypeDescription
rowsStreamSource<RelatedTo<R, UR>>
example
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.

Definition

set(row: R, column: C, value: V): boolean;

Parameters

NameTypeDescription
rowRthe row key
columnCthe column key
valueV
example
const t = HashTableHashColumn.of([1, 2, 3], [1, 4, 5]).toBuilder()
t.set(1, 2, 3) // => false
t.set(1, 3, 8) // => true

updateAt

Updates the value at given row 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

NameTypeDescription
rowRthe row key
columnCthe column key
updateUpdate<V>a function taking the current value and returning a new value
example
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