An instance of the custom sorting class can be used to sort the elements stored in a maxon::BaseArray.
class IntegerSort :
public maxon::BaseSort<IntegerSort, maxon::BASESORTFLAGS::MOVEANDCOPYOBJECTS>
{
public:
{
return a < b;
}
};
FillWithRandomNumbers(numbers);
IntegerSort sort;
sort.Sort(numbers);
Definition: basearray.h:431
ResultMem Resize(Int newCnt, COLLECTION_RESIZE_FLAGS resizeFlags=COLLECTION_RESIZE_FLAGS::DEFAULT)
Resizes the array to contain newCnt elements. If newCnt is smaller than GetCount() all extra elements...
Definition: basearray.h:1247
Int64 Int
signed 32/64 bit int, size depends on the platform
Definition: apibase.h:187
Bool LessThan(UInt a1, UInt a2, UInt b1, UInt b2)
Definition: integer.h:151
#define DiagnosticOutput(formatString,...)
Definition: debugdiagnostics.h:170
maxon::Bool Bool
Definition: ge_sys_math.h:46
#define iferr_return
Definition: resultbase.h:1511
To find elements in the given array, the array must be sorted. The custom sorting class must implement both LessThan
() and IsEqual
().
{
public:
static inline Bool LessThan(CustomDate key, CustomDate element)
{
if (key.year > element.year)
return false;
if (key.year < element.year)
return true;
if (key.month > element.month)
return false;
if (key.month < element.month)
return true;
if (key.day >= element.day)
return false;
return true;
}
static inline Bool IsEqual(CustomDate key, CustomDate element)
{
if (key.year != element.year)
return false;
if (key.month != element.month)
return false;
if (key.day != element.day)
return false;
return true;
}
{
return key < element.year;
}
{
return key == element.year;
}
};
FillWithRandomDates(dates);
DateSort sort;
sort.Sort(dates);
const CustomDate* const date = sort.Find(2000, dates);
if (date)
if (index > 0)
CustomDate newDate;
newDate.year = 1970;
newDate.month = 1;
newDate.day = 1;
sort.FindInsertionIndex(newDate, dates, insertionIndex);
MAXON_ATTRIBUTE_FORCE_INLINE ResultRef< T > Insert(Int position, ARG &&x)
Inserts a new element at index position and constructs it using the forwarded value.
Definition: basearray.h:835
MAXON_ATTRIBUTE_FORCE_INLINE ConstIterator Begin() const
Returns an iterator for the first element.
Definition: basearray.h:1513
MAXON_ATTRIBUTE_FORCE_INLINE Int GetCount() const
Gets the number of array elements.
Definition: basearray.h:600
MAXON_ATTRIBUTE_FORCE_INLINE Bool IsEqual(PREDICATE &&predicate, const T1 &a, const T2 &b)
Definition: collection.h:102