Global

Members

(constant) Heap

Description:
  • Creates a Min Heap data structure.
Source:
Creates a Min Heap data structure.

(constant) Trie

Description:
  • Creates a Trie (prefix tree) data structure.
Source:
Creates a Trie (prefix tree) data structure.

(constant) array2range

Description:
  • Converts a sorted array of numbers into a list of ranges. Consecutive numbers are grouped into a single range [min, max]. Isolated numbers are represented as [num, num].
Source:
Converts a sorted array of numbers into a list of ranges. Consecutive numbers are grouped into a single range [min, max]. Isolated numbers are represented as [num, num].

(constant) bijective2num

Description:
  • Converts a bijective base-k string to a number.
Source:
Converts a bijective base-k string to a number.

(constant) bijective2numBI

Description:
  • Converts a bijective base-k string to a BigInt.
Source:
Converts a bijective base-k string to a BigInt.

(constant) binarySearchArr

Description:
  • Performs a binary search for an exact element in a sorted array.
Source:
Performs a binary search for an exact element in a sorted array.

(constant) binarySearchGE

Description:
  • Performs a binary search for the smallest element greater than or equal to the target.
Source:
Performs a binary search for the smallest element greater than or equal to the target.

(constant) binarySearchLE

Description:
  • Performs a binary search for the largest element less than or equal to the target.
Source:
Performs a binary search for the largest element less than or equal to the target.

(constant) binarySearchRangeIncl

Description:
  • Performs a binary search for a range of elements inclusive of the target. Uses binarySearchGE and binarySearchLE.
Source:
Performs a binary search for a range of elements inclusive of the target. Uses binarySearchGE and binarySearchLE.

(constant) copyCase

Description:
  • Copies the case pattern from one string to another. Handles lower case, upper case, and capitalized strings.
Source:
Copies the case pattern from one string to another. Handles lower case, upper case, and capitalized strings.

(constant) egcd

Description:
  • Extended Euclidean Algorithm. Computes the greatest common divisor (GCD) of a and b, and the coefficients of Bézout's identity.
Source:
Extended Euclidean Algorithm. Computes the greatest common divisor (GCD) of a and b, and the coefficients of Bézout's identity.

(constant) factors

Description:
  • Calculates the prime factorization of a number.
Source:
Calculates the prime factorization of a number.

(constant) factorsBI

Description:
  • Calculates the prime factorization of a BigInt.
Source:
Calculates the prime factorization of a BigInt.

(constant) fromBase64

Description:
  • Decodes a Base64 string. Handles Unicode characters correctly.
Source:
Decodes a Base64 string. Handles Unicode characters correctly.

(constant) fromBase64Url

Description:
  • Decodes a Base64Url string. Replaces '-' with '+' and '_' with '/'.
Source:
Decodes a Base64Url string. Replaces '-' with '+' and '_' with '/'.

(constant) gcd

Description:
  • Calculates the Greatest Common Divisor (GCD) of two numbers.
Source:
Calculates the Greatest Common Divisor (GCD) of two numbers.

(constant) gcdBI

Description:
  • Calculates the Greatest Common Divisor (GCD) of two BigInts.
Source:
Calculates the Greatest Common Divisor (GCD) of two BigInts.

(constant) getType

Description:
  • Returns the type of the value as a lowercase string. More specific than the typeof operator (e.g., distinguishes 'array', 'null', 'date').
Source:
Returns the type of the value as a lowercase string. More specific than the typeof operator (e.g., distinguishes 'array', 'null', 'date').

(constant) gpn

Description:
  • Generalized Pentagonal Numbers (GPN). Formula: P_k = k(3k - 1) / 2 The sequence includes k = 0, 1, -1, 2, -2, 3, -3... https://oeis.org/A001318
Source:
Generalized Pentagonal Numbers (GPN). Formula: P_k = k(3k - 1) / 2 The sequence includes k = 0, 1, -1, 2, -2, 3, -3... https://oeis.org/A001318

(constant) gpnBI

Description:
  • Generalized Pentagonal Numbers (GPN) - BigInt version.
Source:
Generalized Pentagonal Numbers (GPN) - BigInt version.

(constant) heronsFormula

Description:
  • Calculates the area of a triangle given the lengths of its three sides. Uses Heron's formula.
Source:
Calculates the area of a triangle given the lengths of its three sides. Uses Heron's formula.

(constant) heronsFormulaBI

Description:
  • Calculates the area of a triangle given the lengths of its three sides (BigInt version). Returns the integer part of the area (truncated).
Source:
Calculates the area of a triangle given the lengths of its three sides (BigInt version). Returns the integer part of the area (truncated).

(constant) lcm

Description:
  • Calculates the Least Common Multiple (LCM) of two numbers.
Source:
Calculates the Least Common Multiple (LCM) of two numbers.

(constant) lcmBI

Description:
  • Calculates the Least Common Multiple (LCM) of two BigInts.
Source:
Calculates the Least Common Multiple (LCM) of two BigInts.

(constant) matrixAsArray

Description:
  • Represents a 2D matrix as a flat 1D array using a Proxy. Allows accessing elements using a single index (row-major order).
Source:
Represents a 2D matrix as a flat 1D array using a Proxy. Allows accessing elements using a single index (row-major order).

(constant) memoize

Description:
  • Creates a memoized version of a function. Uses a tree structure to store results based on arguments. Compares arguments by reference.
Source:
Creates a memoized version of a function. Uses a tree structure to store results based on arguments. Compares arguments by reference.

(constant) mod

Description:
  • Calculates the modulo of two numbers (Python-like behavior for negative numbers).
Source:
Calculates the modulo of two numbers (Python-like behavior for negative numbers).

(constant) modBI

Description:
  • Calculates the modulo of two BigInts (Python-like behavior for negative numbers).
Source:
Calculates the modulo of two BigInts (Python-like behavior for negative numbers).

(constant) num2bijective

Description:
  • Converts a number to a bijective base-k string.
Source:
Converts a number to a bijective base-k string.

(constant) num2bijectiveBI

Description:
  • Converts a BigInt to a bijective base-k string.
Source:
Converts a BigInt to a bijective base-k string.

(constant) phi

Description:
  • Euler's Totient Function (Phi). Counts the positive integers less than or equal to n that are relatively prime to n. Uses Euler's product formula based on prime factorization.
Source:
Euler's Totient Function (Phi). Counts the positive integers less than or equal to n that are relatively prime to n. Uses Euler's product formula based on prime factorization.

(constant) phiBI

Description:
  • Euler's Totient Function (Phi) - BigInt version.
Source:
Euler's Totient Function (Phi) - BigInt version.

(constant) powMod

Description:
  • Calculates the power of a base to an exponent, optionally modulo a number. Similar to Python's pow(base, exponent, modulus).
Source:
Calculates the power of a base to an exponent, optionally modulo a number. Similar to Python's pow(base, exponent, modulus).

(constant) powModBI

Description:
  • Calculates the power of a base to an exponent, optionally modulo a BigInt. Similar to Python's pow(base, exponent, modulus).
Source:
Calculates the power of a base to an exponent, optionally modulo a BigInt. Similar to Python's pow(base, exponent, modulus).

(constant) range2array

Description:
  • Converts a list of ranges into a flat array of numbers.
Source:
Converts a list of ranges into a flat array of numbers.

(constant) squareRoot

Description:
  • Calculates the square root of a number.
Source:
Calculates the square root of a number.

(constant) squareRootBI

Description:
  • Calculates the integer square root of a BigInt using Newton's method.
Source:
Calculates the integer square root of a BigInt using Newton's method.

(constant) toBase64

Description:
  • Encodes a string to Base64. Handles Unicode characters correctly.
Source:
Encodes a string to Base64. Handles Unicode characters correctly.

(constant) toBase64Url

Description:
  • Encodes a string to Base64Url format. Replaces '+' with '-' and '/' with '_'.
Source:
Encodes a string to Base64Url format. Replaces '+' with '-' and '/' with '_'.

(constant) tonelliShanksBI

Description:
  • Computes the modular square root of n modulo p using the Tonelli-Shanks algorithm. Solves the congruence r^2 = n (mod p) where p is an odd prime.
Source:
Computes the modular square root of n modulo p using the Tonelli-Shanks algorithm. Solves the congruence r^2 = n (mod p) where p is an odd prime.

Methods

add(el) → {number}

Description:
  • Adds an element to the heap.
Source:
Parameters:
Name Type Description
el * The element to add.
Returns:
The new index of the added element.
Type
number

data() → {Array}

Description:
  • Returns the internal array representation of the heap (excluding the dummy first element).
Source:
Returns:
The heap elements.
Type
Array

getData() → {Array}

Description:
  • Returns the internal data structure of the Trie.
Source:
Returns:
The root node of the Trie.
Type
Array

size() → {number}

Description:
  • Returns the number of elements in the heap.
Source:
Returns:
The size of the heap.
Type
number

take() → {*}

Description:
  • Removes and returns the minimum element (root) from the heap.
Source:
Returns:
The minimum element.
Type
*