ArrayUtils
Public Static Methods
| Return | Name | Description |
|---|---|---|
size_t | and_scalar static | Fast intersection (AND) of two sorted arrays. |
size_t | or_scalar static | Fast union (OR) of two sorted arrays. |
size_t | exclude_scalar static | Exclude elements (A - B): elements in A but not in B. |
bool | skip_index_to_id static | Binary search with skip-ahead. |
bool | arrays_equal static | Check if arrays are equal. |
bool | is_sorted static | Check if array is sorted. |
std::vector< uint32_t > | intersect static | Intersection of two vectors (returns new vector) |
std::vector< uint32_t > | union_of static | Union of two vectors (returns new vector) |
std::vector< uint32_t > | exclude static | Exclude elements (a - b) (returns new vector) |
bool | contains static | Check if element exists in sorted array. |
bool | contains static |
and_scalar
static
Parameters
-
AFirst sorted array -
lenALength of array A -
BSecond sorted array -
lenBLength of array B -
outOutput array (allocated by function, caller must delete[])
Returns
Size of intersection (elements in out) Time complexity: O(lenA + lenB) Space complexity: O(min(lenA, lenB))or_scalar
static
Returns
Size of union (elements in out) Time complexity: O(lenA + lenB) Space complexity: O(lenA + lenB)exclude_scalar
static
Parameters
-
srcSource array -
lenSrcLength of source -
filterElements to exclude -
lenFilterLength of filter -
outOutput array (allocated by function)
Returns
Size of result Time complexity: O(lenSrc + lenFilter)skip_index_to_id
static
Parameters
-
curr_indexCurrent index (input/output) -
arraySorted array to search -
array_lenLength of array -
idValue to search for
Returns
true if id was found, false otherwisearrays_equal
static
is_sorted
static
intersect
static
union_of
static
exclude
static
contains
static
contains
static