26#ifndef WATER_ELEMENTCOMPARATOR_H_INCLUDED
27#define WATER_ELEMENTCOMPARATOR_H_INCLUDED
37template <
typename ElementComparator>
42 template <
typename Type>
78template <
class ElementType,
class ElementComparator>
79static void sortArray (ElementComparator& comparator,
80 ElementType*
const array,
83 const bool retainOrderOfEquivalentItems)
87 if (retainOrderOfEquivalentItems)
88 std::stable_sort (array + firstElement, array + lastElement + 1, converter);
90 std::sort (array + firstElement, array + lastElement + 1, converter);
118template <
class ElementType,
class ElementComparator>
120 ElementType*
const array,
121 const ElementType newElement,
125 wassert (firstElement <= lastElement);
130 while (firstElement < lastElement)
132 if (comparator.compareElements (newElement, array [firstElement]) == 0)
139 const int halfway = (firstElement + lastElement) >> 1;
141 if (halfway == firstElement)
143 if (comparator.compareElements (newElement, array [halfway]) >= 0)
148 else if (comparator.compareElements (newElement, array [halfway]) >= 0)
150 firstElement = halfway;
154 lastElement = halfway;
177template <
class ElementType>
186 return (first < second) ? -1 : ((second < first) ? 1 : 0);
uint8_t a
Definition Spc_Cpu.h:141
Definition ElementComparator.h:179
static int compareElements(ParameterType first, ParameterType second)
Definition ElementComparator.h:184
typedef PARAMETER_TYPE(ElementType) ParameterType
* e
Definition inflate.c:1404
ParameterType
Definition CarlaBackend.h:763
#define wassert(expression)
#define WATER_DELETED_FUNCTION
Definition AudioSampleBuffer.h:33
static int findInsertIndexInSortedArray(ElementComparator &comparator, ElementType *const array, const ElementType newElement, int firstElement, int lastElement)
Definition ElementComparator.h:119
void ignoreUnused(const Type1 &) noexcept
Definition MathsFunctions.h:237
static void sortArray(ElementComparator &comparator, ElementType *const array, int firstElement, int lastElement, const bool retainOrderOfEquivalentItems)
Definition ElementComparator.h:79
Definition ElementComparator.h:39
ElementComparator & comparator
Definition ElementComparator.h:46
SortFunctionConverter(ElementComparator &e)
Definition ElementComparator.h:40
SortFunctionConverter & operator=(const SortFunctionConverter &) WATER_DELETED_FUNCTION
bool operator()(Type a, Type b)
Definition ElementComparator.h:43