Skip to content
  • Mark OLESEN's avatar
    ENH: supplementary vector comparison methods · c9730666
    Mark OLESEN authored
    - background: for some application it can be useful to have fully
      sorted points. i.e., sorted by x, followed by y, followed by z.
    
      The default VectorSpace 'operator<' compares *all*
      components. This is seen by the following comparisons
    
      1.  a = (-2.2 -3.3 -4.4)
          b = (-1.1 -2.2 3.3)
    
          (a < b) : True
          Each 'a' component is less than each 'b' component
    
      2.  a = (-2.2 -3.3 -4.4)
          b = (-2.2 3.3 4.4)
    
          (a < b) : False
          The a.x() is not less than b.x()
    
      The static definitions 'less_xyz', 'less_yzx', 'less_zxy'
      instead use comparison of the next components as tie breakers
      (like a lexicographic sort).
      - same type of definition that Pair and Tuple2 use.
    
          a = (-2.2 -3.3 -4.4)
          b = (-2.2 3.3 4.4)
    
          vector::less_xyz(a, b) : True
          The a.x() == b.x(), but a.y() < b.y()
    
       They can be used directly as comparators:
    
          pointField points = ...;
    
          std::sort(points.begin(), points.end(), vector::less_zxy);
    
    ENH: make VectorSpace named access methods noexcept.
    
       Since the addressing range is restricted to enumerated offsets
       (eg, X/Y/Z) into storage, always remains in-range.
       Possible to make constexpr with future C++ versions.
    
    STYLE: VectorSpace 'operator>' defined using 'operator<'
    
    - standard rewriting rule
    c9730666