How to use the @collectable/red-black-tree.set function in @collectable/red-black-tree

To help you get started, we’ve selected a few @collectable/red-black-tree examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github frptools / collectable / packages / sorted-set / src / internals / assignment.ts View on Github external
export function setItem (value: T, map: ValueMap, tree: Sorted, select: SelectorFn|undefined): boolean {
  var entry: SortedSetItem|undefined;

  update(arg => {
    if(isUndefined(arg)) {
      return entry = {
        index: ++_nextIndex,
        view: isDefined(select) ? select(value) : void 0,
        value
      };
    }
  }, value, map);

  if(isDefined(entry)) {
    set, null>(entry, null, tree);
    return true;
  }

  return false;
}

@collectable/red-black-tree

[Collectable.js] Immutable Red-Black Tree

MIT
Latest version published 3 years ago

Package Health Score

46 / 100
Full package analysis

Similar packages