AceCommon
1.4.6
Arduino library for low-level common functions and features with no external dependencies
|
Go to the source code of this file.
Functions | |
template<typename X > | |
bool | ace_common::isSorted (const X list[], size_t size) |
Determine if the elements of the array is sorted This function assumes that 'operator<()' for the value type X is defined. More... | |
template<typename K > | |
bool | ace_common::isSortedByKey (size_t size, K &&key) |
Determine if the abstract array is sorted according to its 'key'. More... | |
template<typename X > | |
bool | ace_common::isReverseSorted (const X list[], size_t size) |
Same as isSorted() but checks for reverse sorting. More... | |
template<typename K > | |
bool | ace_common::isReverseSortedByKey (size_t size, K &&key) |
Same as isSortedByKey() but checks for reverse sorting. More... | |
Templatized functions that determine if an array of things is sorted.
Definition in file isSorted.h.
bool ace_common::isReverseSorted | ( | const X | list[], |
size_t | size | ||
) |
Same as isSorted() but checks for reverse sorting.
X | type of element in list |
list | sorted array of elements of type X (accepts both const array or a pointer to the array) |
size | number of elements |
Definition at line 114 of file isSorted.h.
bool ace_common::isReverseSortedByKey | ( | size_t | size, |
K && | key | ||
) |
Same as isSortedByKey() but checks for reverse sorting.
K | lambda expression or function pointer that returns some unspecified value at index 'i'. The type of the value is inferred automatically using the 'auto' keyword. |
size | number of elements in the array |
key | a function or lambda expression that returns the value at index 'i'. If the 'key' inlined, I think the compiler is smart enough to inline the 'key' into this code, and avoid a function call. |
Definition at line 141 of file isSorted.h.
bool ace_common::isSorted | ( | const X | list[], |
size_t | size | ||
) |
Determine if the elements of the array is sorted This function assumes that 'operator<()' for the value type X
is defined.
X | type of element in list |
list | sorted array of elements of type X (accepts both const array or a pointer to the array) |
size | number of elements |
Definition at line 46 of file isSorted.h.
bool ace_common::isSortedByKey | ( | size_t | size, |
K && | key | ||
) |
Determine if the abstract array is sorted according to its 'key'.
Returns true if sorted, false if not sorted. Returns false if the size of the array is 0.
This function assumes that 'operator<()' for the value type of key
is defined.
Performance Note: Many compilers (all?) are not able to opimize away the function call overhead of the lambda expression. If performance is critical, you should copy and modify this code instead.
K | lambda expression or function pointer that returns some unspecified value at index 'i'. The type of the value is inferred automatically using the 'auto' keyword. |
size | number of elements in the array |
key | a function or lambda expression that returns the value at index 'i'. If the 'key' inlined, I think the compiler is smart enough to inline the 'key' into this code, and avoid a function call. |
Definition at line 93 of file isSorted.h.