Staquia API
    Preparing search index...

    Interface IDigits

    A number as a map of digits by key: the key is the power of the base, so a higher key is a more significant digit, and negative keys are the digits after the point. See Digits.

    interface IDigits {
        _map: Map<number, number>;
        lowerBound: number;
        upperBound: number;
        clone(): IDigits;
        compact(): void;
        compare(other: IDigits): Ordering;
        equal(other: IDigits): boolean;
        expand(size: number): void;
        extend(size: number): void;
        get(key: number): number;
        greater(this: IDigits, other: IDigits): boolean;
        greaterOrEqual(this: IDigits, other: IDigits): boolean;
        isEmpty(): boolean;
        isKeyZero(key: number): boolean;
        isZero(): boolean;
        less(this: IDigits, other: IDigits): boolean;
        lessOrEqual(this: IDigits, other: IDigits): boolean;
        pop(): void;
        reference(number: IDigits): void;
        remove(key: number): boolean;
        set(key: number, value: number): void;
        stack(other: IDigits): void;
        update(key: number, offset: number): void;
    }

    Hierarchy (View Summary)

    Implemented by

    Index

    Properties

    _map: Map<number, number>

    The digits by key.

    lowerBound: number

    The key of the least significant digit.

    upperBound: number

    The key of the most significant digit.

    Methods

    • Removes the zeroes from the most significant side (the leading zeroes). A number of only zeroes keeps a single 0.

      Returns void

    • Compares this with other, like a sort comparator.

      Parameters

      • other: IDigits

        The object to compare with.

      Returns Ordering

      "less" if this goes before other, "equal" if they have the same value, "greater" if it goes after.

      import Staquia from "staquia";

      const system = Staquia.create("!", "a", "z", 5, 15, 0.15);
      const a = system.forge("mmmmm!m");
      const b = system.forge("mmmmn");

      if (a.ok && b.ok) console.log(a.value.compare(b.value)); // "less"
    • Checks if this and other have the same value.

      Parameters

      • other: IDigits

        The object to compare with.

      Returns boolean

      true if both have the same value.

      import Staquia from "staquia";

      const system = Staquia.create("!", "a", "z", 5, 15, 0.15);
      const a = system.forge("mmmmm");
      const b = system.forge("mmmmm!");

      // Zeroes to the right don't change the value
      if (a.ok && b.ok) console.log(a.value.equal(b.value)); // true
    • Adds zeroes above the most significant digit (on the left of the number).

      Parameters

      • size: number

        How many zeroes to add.

      Returns void

    • Shifts the digits up and adds zeroes at the lowest keys (on the right of the number), like multiplying it by base ^ size.

      Parameters

      • size: number

        How many zeroes to add.

      Returns void

    • Gets the digit at a key, 0 if there is none.

      Parameters

      • key: number

        The key of the digit.

      Returns number

    • Checks if the number has no digit set at all: nothing at the key 0 and both bounds 0.

      Returns boolean

    • Checks if the digit at a key is 0 (or missing).

      Parameters

      • key: number

        The key of the digit.

      Returns boolean

    • Checks if the number is a single 0: both bounds are 0 and the digit at the key 0 is 0 or missing.

      Returns boolean

    • Checks if this goes before other.

      Parameters

      • this: IDigits

        The left side of the comparison.

      • other: IDigits

        The right side of the comparison.

      Returns boolean

      true if this < other.

      import Staquia from "staquia";

      const system = Staquia.create("!", "a", "z", 5, 15, 0.15);
      const a = system.forge("mmmmm!m");
      const b = system.forge("mmmmn");

      if (a.ok && b.ok) {
      console.log(a.value.less(b.value)); // true
      console.log(a.value.greater(b.value)); // false
      }
    • Moves the digits and bounds of another number into this one, without copying them. The other number is left without digits and must not be used after it.

      Parameters

      • number: IDigits

        The number to take the digits from.

      Returns void

    • Removes the digit at a key.

      Parameters

      • key: number

        The key of the digit.

      Returns boolean

      true if there was a digit to remove, false otherwise.

    • Sets the digit at a key.

      Parameters

      • key: number

        The key of the digit.

      • value: number

        The digit.

      Returns void

    • Adds the digits of another number above the most significant digit of this one.

      Parameters

      • other: IDigits

        The number whose digits are added.

      Returns void

    • Adds an offset to the digit at a key. It doesn't carry: resolveOverflow does.

      Parameters

      • key: number

        The key of the digit.

      • offset: number

        The value to add (negative to subtract).

      Returns void