This file contains the implementation of the array
data structure, which is a resizeable ordered collection of elements with generic type T
. In addition, the file contains global helper functions for working with arrays, such as resizing, linear and binary search, insertion sort, and quicksort. The pair
structure is also defined here.
This file also contains functions that perform set operations on sorted arrays and native arrays, such as union, intersection, subtraction, and subset.
Classes, functions, and variables in this file | |
---|---|
#define | RESIZE_FACTOR |
struct | is_resizeable |
bool | resize (T *& data, const SizeType & new_capacity) |
void | expand_capacity (SizeType & capacity, size_t new_length) |
bool | expand (T *& data, SizeType & capacity, size_t new_length) |
bool | ensure_capacity (T *& data, SizeType & capacity, size_t new_length) |
SizeType | index_of (const Key & element, const T * data, const SizeType & length, const SizeType & start = 0) |
unsigned int | last_index_of (const Key & element, const T * data, const SizeType & length) |
struct | array |
bool | array_init (array< T > & m, size_t initial_capacity) |
size_t | size (const array< T > & m) |
void | swap (array< T > & a, array< T > & b) |
bool | operator == (const array< T > & a, const array< T > & b) |
bool | operator != (const array< T > & a, const array< T > & b) |
void | insertion_sort (T * keys, unsigned int length) |
void | insertion_sort (T * keys, unsigned int length, const Sorter & sorter) |
void | insertion_sort (K * keys, V * values, unsigned int length) |
void | insertion_sort (K * keys, V * values, unsigned int length, const Sorter & sorter) |
void | insertion_sort (array< T > & keys) |
void | insertion_sort (array< T > & keys, const Sorter & sorter) |
void | insertion_sort (array< K > & keys, array< V > & values) |
void | insertion_sort (array< K > & keys, array< V > & values, const Sorter & sorter) |
void | reverse (T * array, unsigned int length) |
void | reverse (array< T > & array) |
void | quick_sort (T * keys, unsigned int length) |
void | quick_sort (T * keys, unsigned int length, const Sorter & sorter) |
void | quick_sort (K * keys, V * values, unsigned int length) |
void | quick_sort (K * keys, V * values, unsigned int length, const Sorter & sorter) |
void | quick_sort (array< T > & keys) |
void | quick_sort (array< T > & keys, const Sorter & sorter) |
void | quick_sort (array< K > & keys, array< V > & values) |
void | quick_sort (array< K > & keys, array< V > & values, const Sorter & sorter) |
void | sort (T * keys, unsigned int length) |
void | sort (T * keys, unsigned int length, const Sorter & sorter) |
void | sort (K * keys, V * values, unsigned int length) |
void | sort (K * keys, V * values, unsigned int length, const Sorter & sorter) |
void | sort (array< T > & keys) |
void | sort (array< T > & keys, const Sorter & sorter) |
void | sort (array< K > & keys, array< V > & values) |
void | sort (array< K > & keys, array< V > & values, const Sorter & sorter) |
bool | is_sorted (const T * items, size_t length, const Sorter & sorter) |
bool | is_sorted (const array< T > & items, const Sorter & sorter) |
struct | default_sorter |
struct | pointer_sorter |
unsigned int | unique (T * array, size_t length) |
void | unique (array< T > & a) |
void | shuffle (T * array, unsigned int length) |
void | shuffle (K * keys, V * values, unsigned int length) |
void | shuffle (array< T > & items) |
unsigned int | linear_search (const T * a, const T & b, unsigned int start, unsigned int end) |
unsigned int | strict_linear_search (const T * a, const T & b, unsigned int start, unsigned int end) |
unsigned int | reverse_strict_linear_search (const T * a, const T & b, unsigned int start, unsigned int end) |
unsigned int | binary_search (const T * a, const T & b, unsigned int min, unsigned int max) |
struct | pair |
void | shift_right (T * list, unsigned int length, unsigned int index) |
void | shift_left (T * list, unsigned int index) |
void | set_union (UnionBoth union_both, UnionFirst union_first, UnionSecond union_second, const T * first, unsigned int first_length, const T * second, unsigned int second_length) |
void | set_union (T * dst, SizeType & dst_length, const T * first, unsigned int first_length, const T * second, unsigned int second_length) |
bool | set_union (array< T > & dst, const T * first, unsigned int first_length, const T * second, unsigned int second_length) |
bool | set_union (array< T > & dst, const array< T > & first, const array< T > & second) |
bool | set_union (array< T > & dst, const ArraySetCollection & arrays, unsigned int array_count) |
bool | set_intersect (Intersect intersect, const T * first, unsigned int first_length, const T * second, unsigned int second_length) |
bool | set_intersect (T * intersection, SizeType & intersection_length, const T * first, unsigned int first_length, const T * second, unsigned int second_length) |
bool | set_intersect (array< T > & intersection, const T * first, unsigned int first_length, const T * second, unsigned int second_length) |
bool | set_intersect (array< T > & intersection, const array< T > & first, const array< T > & second) |
void | set_intersect (T * first, SizeType & first_length, const T * second, unsigned int second_length) |
void | set_intersect (array< T > & first, const T * second, unsigned int second_length) |
void | set_intersect (array< T > & first, const array< T > & second) |
bool | has_intersection (const T * first, unsigned int first_length, const T * second, unsigned int second_length) |
bool | has_intersection (const array< T > & first, const array< T > & second) |
bool | is_subset (const T * first, unsigned int first_length, const T * second, unsigned int second_length) |
void | set_subtract (EmitFunction emit, const T * first, unsigned int first_length, const T * second, unsigned int second_length) |
void | set_subtract (T * dst, SizeType & dst_length, const T * first, unsigned int first_length, const T * second, unsigned int second_length) |
bool | set_subtract (array< T > & dst, const T * first, unsigned int first_length, const T * second, unsigned int second_length) |
bool | set_subtract (array< T > & dst, const array< T > & first, const array< T > & second) |
void | set_subtract (T * first, SizeType & first_length, const T * second, unsigned int second_length) |
void | set_subtract (array< T > & first, const array< T > & second) |
The multiplicative factor by which array capacity is changed.
This type trait is true_type if and only if T
is class with a public function void on_resize()
.
data
with the requested capacity new_capacity
.SizeType | a type that satisfies is_integral. |
T | the generic type of the elements in |
data | the array to resize. |
new_capacity | the requested size. |
true
on success; data
may point to a different memory address.
false
on failure; data
is unchanged.
This function multiplies capacity
by RESIZE_FACTOR. It then repeats this until capacity >= new_length
.
For a given requested length new_length
, this function calls expand_capacity() to determine the new capacity
of the native array data
. The function then attempts to resize the array with this capacity. Note this function does not check whether new_length <= capacity
.
T *& | data, | |
SizeType & | capacity, | |
size_t | new_length | ) |
For a given requested length new_length
, this function expands the native array data
by factors of RESIZE_FACTOR until capacity >= new_length
. If initially new_length <= capacity
, this function does nothing.
const Key & | element, | |
const T * | data, | |
const SizeType & | length, | |
const SizeType & | start = 0 | ) |
data
to find the smallest index i >= start
such that element == data[i]
.Key | a generic type for which operator |
T | a generic type for which operator |
an index in start, start + 1, ..., length - 1
if the element was found.
length
if the element was not found.
const Key & | element, | |
const T * | data, | |
const SizeType & | length | ) |
data
to find the largest index i
such that element == data[i]
.Key | a generic type for which operator |
T | a generic type for which operator |
an index in 0, 1, ..., length - 1
if the element was found.
static_cast<unsigned int>(-1)
if the element was not found.
A resizeable sequence of objects, stored contiguously, each with generic type T
. This structure does not automatically initialize or free its elements, and so the user must appropriately free each element before the array is destroyed.
In the following example, we demonstrate a simple use-case of array. Here, a
is automatically freed by the destructor since it was initialized on the stack. The expected output is -1 -1 0 3
.
#include <core/array.h> #include <stdio.h> using namespace core; int main() { array<int> a = array<int>(8); a.add(-1); a.add(-4); a.add(3); a.add(0); a.remove(1); printf("%d ", a[0]); for (int element : a) printf("%d ", element); }
However, if a
is not allocated on the stack, the destructor will not be automatically called, and so it must be freed manually using core::free
or array::free
.
#include <core/array.h> #include <stdio.h> using namespace core; int main() { array<int>& a = *((array<int>*) alloca(sizeof(array<int>))); array_init(a, 8); a.add(-1); a.add(-4); a.add(3); a.add(0); a.remove(1); printf("%d ", a[0]); for (int element : a) printf("%d ", element); free(a); }
Also note that a number of member functions require that T
be CopyAssignable. In other cases, elements should be added manually to the underlying native array array::data. This structure also defines array::begin and array::end, similar to Standard Template Library iterators, which enables the use of the range-based for loop in the example below. In this example, the expected output is first second
.
#include <core/array.h> #include <stdio.h> #include <string.h> using namespace core; struct custom_string { char* buffer; static void free(custom_string& s) { core::free(s.buffer); } }; bool init(custom_string& s, const char* src) { s.buffer = (char*) malloc(sizeof(char) * (strlen(src) + 1)); if (s.buffer == NULL) return false; memcpy(s.buffer, src, sizeof(char) * (strlen(src) + 1)); return true; } int main() { array<custom_string> a = array<custom_string>(8); init(a[0], "first"); init(a[1], "second"); a.length = 2; for (const custom_string& s : a) printf("%s ", s.buffer); for (custom_string& s : a) free(s); }Note in the above example that since the array struct does not automatically free its elements, they must be freed manually.
Public members | |
---|---|
T * | data |
size_t | length |
size_t | capacity |
array (size_t initial_capacity) | |
T & | operator [] (size_t index) |
const T & | operator [] (size_t index) const |
void | clear () |
void | remove (size_t index) |
bool | ensure_capacity (size_t new_length) |
bool | append (const T * elements, size_t size) |
bool | contains (const Key & element) const |
unsigned int | index_of (const Key & element) const |
unsigned int | index_of (const Key & element, SizeType start) const |
T & | first () |
const T & | first () const |
T & | last () |
const T & | last () const |
bool | add (const T & element) |
T | pop () |
T * | begin () |
T * | end () |
const T * | begin () const |
const T * | end () const |
static void | move (const array< T > & src, array< T > & dst) |
static void | free (array< T > & a) |
The underlying native array of elements.
The length of the array.
The capacity of array::data.
size_t | initial_capacity | ) |
Constructs an array with zero size and the given initial_capacity
.
size_t | index | ) |
Returns a reference to the element at the given index
. No bounds-checking is performed.
size_t | index | ) const |
Returns a const reference to the element at the given index
. No bounds-checking is performed.
Sets the length of the array to 0
. Any elements are not freed.
size_t | index | ) |
Moves the last element in the array to the position given by index
and decrements array::length by 1
. The element initially at index
is not freed.
For a given requested length new_length
, this function expands the array by factors of RESIZE_FACTOR until array::capacity >= new_length
. If initially new_length <= array::capacity
, this function does nothing. If the resize operation moved array::data to a new memory address, and T
satisfies is_resizeable, then x.on_resize()
is called for every element x
in the array.
const T * | elements, | |
size_t | size | ) |
T |
element
exists in this array.Key | a generic type for which operator |
i
such that element == array::data[i]
.Key | a generic type for which operator |
an index in 0, 1, ..., array::length - 1
if the element was found.
array::length
if the element was not found.
const Key & | element, | |
SizeType | start | ) const |
i >= start
such that element == array::data[i]
.Key | a generic type for which operator |
an index in start, start + 1, ..., length - 1
if the element was found.
length
if the element was not found.
Returns a reference to array::data[0]
, ignoring any bounds.
Returns a const reference to array::data[0]
, ignoring any bounds.
Returns a reference to array::data[array::length - 1]
, ignoring any bounds.
Returns a const reference to array::data[array::length - 1]
, ignoring any bounds.
const T & | element | ) |
T
is not CopyAssignable. In such a case, addition should be performed manually using the public fields.T | is CopyAssignable. |
Returns the element at array::length - 1
and decrements array::length by 1
, ignoring any bounds.
Returns an iterator to the beginning of the array.
Returns an iterator to the end of the array.
Returns a const iterator to the beginning of the array.
Returns a const iterator to the end of the array.
Copies the underlying fields from src
into dst
, effectively moving the array from src
into dst
.
array< T > & | a | ) |
Frees array::data. This should not be used if a
was constructed on the stack, as the destructor will automatically free array::data. The elements of a
are not freed.
Initializes the array m
with the given initial_capacity
.
Returns array::length of m
.
Swaps the underlying buffers of the given arrays.
Compares the two given arrays and returns true if and only if a.length == b.length
and there is no index i
such that a.data[i] != b.data[i]
.
Compares the two given arrays and returns true if and only if a.length != b.length
or there is some index i
such that a.data[i] != b.data[i]
.
keys
with given length
.T | is CopyAssignable, CopyConstructible, and LessThanComparable. |
T * | keys, | |
unsigned int | length, | |
const Sorter & | sorter | ) |
keys
with given length
and sorter
.T | satisfies is_moveable, and for which a function |
keys
and values
with given length
.K | is CopyAssignable, CopyConstructible, and LessThanComparable. |
V |
K * | keys, | |
V * | values, | |
unsigned int | length, | |
const Sorter & | sorter | ) |
keys
and values
with given length
and sorter
.K | satisfies is_moveable, and for which a function |
V | satisfies is_moveable. |
keys
.T | is CopyAssignable, CopyConstructible, and LessThanComparable. |
keys
with the given sorter
.T | satisfies is_moveable, and for which a function |
keys
and values
.K | is CopyAssignable, CopyConstructible, and LessThanComparable. |
V |
array< K > & | keys, | |
array< V > & | values, | |
const Sorter & | sorter | ) |
keys
and values
with the given sorter
.K | satisfies is_moveable, and for which a function |
V | satisfies is_moveable. |
array
with given length
.T | satisfies is_swappable. |
array
.T | satisfies is_swappable. |
keys
with given length
. This function assumes length > 0
. If the preprocessor NDEBUG
is not defined, this function outputs a warning when length == 0
.T | is CopyConstructible, LessThanComparable, and is_swappable. |
T * | keys, | |
unsigned int | length, | |
const Sorter & | sorter | ) |
keys
with given length
and sorter
. This function assumes length > 0
. If the preprocessor NDEBUG
is not defined, this function outputs a warning when length == 0
.T | a generic type that satisfies is_swappable, and for which a function |
keys
and values
with given length
. This function assumes length > 0
. If the preprocessor NDEBUG
is not defined, this function outputs a warning when length == 0
.K | is CopyConstructible, LessThanComparable, and is_swappable. |
V | satisfies is_swappable. |
K * | keys, | |
V * | values, | |
unsigned int | length, | |
const Sorter & | sorter | ) |
keys
and values
with given length
and sorter
. This function assumes length > 0
. If the preprocessor NDEBUG
is not defined, this function outputs a warning when length == 0
.K | a generic type that satisfies is_swappable, and for which a function |
V | satisfies is_swappable. |
keys
. This function assumes length > 0
. If the preprocessor NDEBUG
is not defined, this function outputs a warning when length == 0
.T | is CopyConstructible, LessThanComparable, and is_swappable. |
keys
with the given sorter
. This function assumes length > 0
. If the preprocessor NDEBUG
is not defined, this function outputs a warning when length == 0
.T | a generic type that satisfies is_swappable, and for which a function |
keys
and values
. This function assumes length > 0
. If the preprocessor NDEBUG
is not defined, this function outputs a warning when length == 0
.K | is CopyConstructible, LessThanComparable, and is_swappable. |
V | satisfies is_swappable. |
array< K > & | keys, | |
array< V > & | values, | |
const Sorter & | sorter | ) |
keys
and values
with the given sorter
. This function assumes length > 0
. If the preprocessor NDEBUG
is not defined, this function outputs a warning when length == 0
.K | a generic type that satisfies is_swappable, and for which a function |
V | satisfies is_swappable. |
keys
with given length
. To improve performance, the Quicksort switches to insertion sort for small partitions. This function assumes length > 0
. If the preprocessor NDEBUG
is not defined, this function outputs a warning when length == 0
.T | is CopyAssignable, CopyConstructible LessThanComparable, and is_swappable. |
keys
with given length
and sorter
. To improve performance, the Quicksort switches to insertion sort for small partitions. This function assumes length > 0
. If the preprocessor NDEBUG
is not defined, this function outputs a warning when length == 0
.T | a generic type that satisfies is_swappable and is_moveable, and for which a function |
keys
and values
with given length
. To improve performance, the Quicksort switches to insertion sort for small partitions. This function assumes length > 0
. If the preprocessor NDEBUG
is not defined, this function outputs a warning when length == 0
.K | is CopyAssignable, CopyConstructible LessThanComparable, and is_swappable. |
V | satisfies is_swappable and is_moveable. |
K * | keys, | |
V * | values, | |
unsigned int | length, | |
const Sorter & | sorter | ) |
keys
and values
with given length
and sorter
. To improve performance, the Quicksort switches to insertion sort for small partitions. This function assumes length > 0
. If the preprocessor NDEBUG
is not defined, this function outputs a warning when length == 0
.K | a generic type that satisfies is_swappable and is_moveable, and for which a function |
V | satisfies is_swappable and is_moveable. |
keys
. To improve performance, the Quicksort switches to insertion sort for small partitions. This function assumes length > 0
. If the preprocessor NDEBUG
is not defined, this function outputs a warning when length == 0
.T | is CopyAssignable, CopyConstructible LessThanComparable, and is_swappable. |
keys
with the given sorter
. To improve performance, the Quicksort switches to insertion sort for small partitions. This function assumes length > 0
. If the preprocessor NDEBUG
is not defined, this function outputs a warning when length == 0
.T | a generic type that satisfies is_swappable and is_moveable, and for which a function |
keys
and values
. To improve performance, the Quicksort switches to insertion sort for small partitions. This function assumes length > 0
. If the preprocessor NDEBUG
is not defined, this function outputs a warning when length == 0
.K | is CopyAssignable, CopyConstructible LessThanComparable, and is_swappable. |
V | satisfies is_swappable and is_moveable. |
array< K > & | keys, | |
array< V > & | values, | |
const Sorter & | sorter | ) |
keys
and values
with the given sorter
. To improve performance, the Quicksort switches to insertion sort for small partitions. This function assumes length > 0
. If the preprocessor NDEBUG
is not defined, this function outputs a warning when length == 0
.K | a generic type that satisfies is_swappable and is_moveable, and for which a function |
V | satisfies is_swappable and is_moveable. |
const T * | items, | |
size_t | length, | |
const Sorter & | sorter | ) |
true
if and only if the given native array items
with the given length
is sorted in non-decreasing order.T | a generic type for which a function |
true
if and only if the given array items
is sorted in non-decreasing order.T | a generic type for which a function |
The default_sorter provides a default implementation of bool less_than(const T&, const T&, const default_sorter&)
where the comparison is done using the operator <
.
The pointer_sorter compares items using the <
operator on the dereferenced arguments.
array
with given length
and returns the new length. Note the deleted elements are not freed.T | is CopyAssignable. |
array
with given and returns the new length. Note the deleted elements are not freed.T | is CopyAssignable. |
keys
and values
with given length
.T | satisfies is_swappable. |
array
.T | satisfies is_swappable. |
const T * | a, | |
const T & | b, | |
unsigned int | start, | |
unsigned int | end | ) |
Given sorted array a
, this function finds the smallest index i
such that a[i] >= b
and i >= start
and i < end
.
const T * | a, | |
const T & | b, | |
unsigned int | start, | |
unsigned int | end | ) |
Given sorted array a
, this function finds the smallest index i
such that a[i] > b
and i >= start
and i < end
.
const T * | a, | |
const T & | b, | |
unsigned int | start, | |
unsigned int | end | ) |
Given sorted array a
, this function finds the smallest index i
such that a[i] > b
and i >= start
and i < end
.
const T * | a, | |
const T & | b, | |
unsigned int | min, | |
unsigned int | max | ) |
Given sorted array a
, this function finds the smallest index i
such that a[i] >= b
and i >= min
and i <= max
.
A simple pair data structure.
Public members | |
---|---|
K | key |
V | value |
The key object in the field.
The value object in the field.
i >= index
, this function moves each element at i
to index i + 1
.T | satisfies is_moveable. |
i < index
, this function moves each element at i + 1
to index i
.T | satisfies is_moveable. |
UnionBoth | union_both, | |
UnionFirst | union_first, | |
UnionSecond | union_second, | |
const T * | first, | |
unsigned int | first_length, | |
const T * | second, | |
unsigned int | second_length | ) |
first
and second
, this function visits their elements sequentially, and:For every element x
that appears in both arrays, union_both(x, i, j)
is called where first[i] == x
and second[j] == x
.
For every element x
that appears in first
but not second
, union_first(x, i, j)
is called where first[i] == x
, and j
is the smallest such index where second[j] > x
.
For every element x
that appears in second
but not first
, union_second(x, i, j)
is called where second[j] == x
, and i
is the smallest such index where first[i] > x
.
The visited elements are also ordered.
T | a generic type for which the operators |
RemoveDuplicates | if |
T * | dst, | |
SizeType & | dst_length, | |
const T * | first, | |
unsigned int | first_length, | |
const T * | second, | |
unsigned int | second_length | ) |
first
and second
, compute their union and appends the result to dst
. The union is also ordered. This function assumes dst
has sufficient capacity to store the union.T | satisfies CopyAssignable and implements the operators |
RemoveDuplicates | if |
array< T > & | dst, | |
const T * | first, | |
unsigned int | first_length, | |
const T * | second, | |
unsigned int | second_length | ) |
first
and second
, compute their union and appends the result to dst
. The union is also ordered.T | satisfies CopyAssignable and implements the operators |
RemoveDuplicates | if |
array< T > & | dst, | |
const array< T > & | first, | |
const array< T > & | second | ) |
first
and second
, compute their union and appends the result to dst
. The union is also ordered.T | satisfies CopyAssignable and implements the operators |
RemoveDuplicates | if |
array< T > & | dst, | |
const ArraySetCollection & | arrays, | |
unsigned int | array_count | ) |
arrays
, compute their union and appends the result to dst
. The union is also ordered. NOTE: this function assumes the given arrays are all non-empty.T | satisfies CopyAssignable and implements the operators |
ArraySetCollection | a collection type where each element is accessed using |
Intersect | intersect, | |
const T * | first, | |
unsigned int | first_length, | |
const T * | second, | |
unsigned int | second_length | ) |
first
and second
, this function visits their elements sequentially, and for every element x
that exists in both arrays, intersect(i, j)
is called where first[i] == x
and second[j] == x
. The visited elements are also ordered.T | a generic type for which the operators |
BinarySearch | if |
T * | intersection, | |
SizeType & | intersection_length, | |
const T * | first, | |
unsigned int | first_length, | |
const T * | second, | |
unsigned int | second_length | ) |
first
and second
, compute the intersection and append it to the native array intersection
. The computed intersection is also ordered. This function assumes intersection
has sufficient capacity.T | satisfies CopyAssignable and implements the operators |
BinarySearch | if |
array< T > & | intersection, | |
const T * | first, | |
unsigned int | first_length, | |
const T * | second, | |
unsigned int | second_length | ) |
first
and second
, compute the intersection and append it to the array intersection
. The computed intersection is also ordered.T | satisfies CopyAssignable and implements the operators |
BinarySearch | if |
array< T > & | intersection, | |
const array< T > & | first, | |
const array< T > & | second | ) |
first
and second
, compute the intersection and append it to the array intersection
. The computed intersection is also ordered.T | satisfies CopyAssignable and implements the operators |
BinarySearch | if |
T * | first, | |
SizeType & | first_length, | |
const T * | second, | |
unsigned int | second_length | ) |
first
and second
, compute the intersection in-place and store it in first
. The computed intersection is also ordered.T | satisfies CopyAssignable and implements the operators |
BinarySearch | if |
array< T > & | first, | |
const T * | second, | |
unsigned int | second_length | ) |
first
and ordered native array second
, compute the intersection in-place and store it in first
. The computed intersection is also ordered.T | satisfies CopyAssignable and implements the operators |
BinarySearch | if |
array< T > & | first, | |
const array< T > & | second | ) |
first
and second
, compute the intersection in-place and store it in first
. The computed intersection is also ordered.T | satisfies CopyAssignable and implements the operators |
BinarySearch | if |
const T * | first, | |
unsigned int | first_length, | |
const T * | second, | |
unsigned int | second_length | ) |
first
and second
is non-empty, where first
and second
are ordered native arrays.T | a generic type that implements the operators |
BinarySearch | if |
const array< T > & | first, | |
const array< T > & | second | ) |
first
and second
is non-empty, where first
and second
are ordered arrays.T | a generic type that implements the operators |
BinarySearch | if |
const T * | first, | |
unsigned int | first_length, | |
const T * | second, | |
unsigned int | second_length | ) |
first
is a subset of second
, where first
and second
are ordered native arrays.T | a generic type that implements the operators |
BinarySearch | if |
EmitFunction | emit, | |
const T * | first, | |
unsigned int | first_length, | |
const T * | second, | |
unsigned int | second_length | ) |
first
and second
, this function visits their elements sequentially, and for every element x
that exists in first
but not in second
, emit(i)
is called where first[i] == x
. The visited elements are also ordered.T | a generic type that implements the operators |
BinarySearch | if |
T * | dst, | |
SizeType & | dst_length, | |
const T * | first, | |
unsigned int | first_length, | |
const T * | second, | |
unsigned int | second_length | ) |
first
and second
, this function computes the set difference between first
and second
and stores the result in dst
. This function assumes dst
has sufficient capacity. The set difference is also ordered.T | satisfies CopyAssignable and implements the operators |
BinarySearch | if |
array< T > & | dst, | |
const T * | first, | |
unsigned int | first_length, | |
const T * | second, | |
unsigned int | second_length | ) |
first
and second
, this function computes the set difference between first
and second
and stores the result in dst
. The set difference is also ordered.T | satisfies CopyAssignable and implements the operators |
BinarySearch | if |
array< T > & | dst, | |
const array< T > & | first, | |
const array< T > & | second | ) |
first
and second
, this function computes the set difference between first
and second
and stores the result in dst
. The set difference is also ordered.T | satisfies CopyAssignable and implements the operators |
BinarySearch | if |
T * | first, | |
SizeType & | first_length, | |
const T * | second, | |
unsigned int | second_length | ) |
first
and second
, this function computes the set difference in-place between first
and second
and stores the result in first
. The set difference is also ordered.T | satisfies CopyAssignable and implements the operators |
BinarySearch | if |
array< T > & | first, | |
const array< T > & | second | ) |
first
and second
, this function computes the set difference in-place between first
and second
and stores the result in first
. The set difference is also ordered.T | satisfies CopyAssignable and implements the operators |
BinarySearch | if |