Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Sorting a multidimensional basearray

    SDK Help
    0
    2
    197
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        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));
        	...
        
        1 Reply Last reply Reply Quote 0
        • First post
          Last post