Sorting a multidimensional basearray
-
On 16/04/2014 at 13:16, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R15
Platform: Windows ;
Language(s) : C++ ;---------
Using a SortedArray is perfect for sorting values.
Now I like to have a BaseArray with points (x,y,z), so 3 dimension.
How to sort such a point (3 dimensional) array for example on x value.
So, the point with the lowest x value first, and so on.Pim
-
On 16/04/2014 at 14:45, xxxxxxxx wrote:
In fact, it is easier than I thought.
Just define it as a vector and change the inline code.class MySortedIntegerArray : public maxon::SortedArray<MySortedIntegerArray, maxon::BaseArray<Vector> > { public: MySortedIntegerArray() {} // your sorted array must implement a LessThan() method static inline maxon::Bool LessThan(Vector a, Vector b) { return a.x < b.x; } }; void SortedArrayDemo() { MySortedIntegerArray test; test.Append(Vector(25,2,3)); test.Append(Vector(2,20,2)); ...