IntSetUtils

Namespace

IntSetUtils

Description:
  • Provides high-performance utility functions for set operations on sorted Int32Arrays. All functions assume input arrays are sorted and contain unique elements. Designed for efficiency with minimal garbage collection overhead.

Source:

Methods

(static) difference(arrA, arrB) → {Int32Array}

Description:
  • Computes the difference of two sorted Int32Arrays (A - B). The resulting array will contain elements present in arrA but not in arrB, sorted in ascending order. Linear time complexity O(|A| + |B|).

Source:
Parameters:
Name Type Description
arrA Int32Array

The minuend sorted Int32Array.

arrB Int32Array

The subtrahend sorted Int32Array.

Returns:

A new sorted Int32Array containing the difference (A - B) of elements.

Type
Int32Array

(static) has(sortedArr, value) → {boolean}

Description:
  • Binary Search for value existence.

Source:
Parameters:
Name Type Description
sortedArr Int32Array

The sorted array to search within.

value number

The value to search for.

Returns:

True if the value is found in the array.

Type
boolean

(static) intersection(arrA, arrB) → {Int32Array}

Description:
  • Computes the intersection of two sorted Int32Arrays (A ∩ B). The resulting array will contain only the elements common to both input arrays, sorted in ascending order. Linear time complexity O(|A| + |B|).

Source:
Parameters:
Name Type Description
arrA Int32Array

The first sorted Int32Array.

arrB Int32Array

The second sorted Int32Array.

Returns:

A new sorted Int32Array containing the intersection of elements.

Type
Int32Array

(static) sortAndUnique(rawArr) → {Int32Array}

Description:
  • Sorts an Int32Array in ascending order and removes duplicate elements. This function mutates the input array by sorting it in-place and then returns a subarray view containing only the unique elements.

Source:
Parameters:
Name Type Description
rawArr Int32Array

The Int32Array to sort and deduplicate. This array will be mutated.

Returns:

A subarray view of the input rawArr containing sorted unique elements.

Type
Int32Array

(static) union(arrA, arrB) → {Int32Array}

Description:
  • Computes the union of two sorted Int32Arrays (A U B). The resulting array will contain all unique elements from both input arrays, sorted in ascending order. Linear time complexity O(|A| + |B|).

Source:
Parameters:
Name Type Description
arrA Int32Array

The first sorted Int32Array.

arrB Int32Array

The second sorted Int32Array.

Returns:

A new sorted Int32Array containing the union of elements.

Type
Int32Array