diff liboctave/idx-vector.h @ 10273:3a8c13b71612

implement special-case optimization for sort of index vectors
author Jaroslav Hajek <highegg@gmail.com>
date Mon, 08 Feb 2010 11:16:52 +0100
parents 4c0cdbe0acca
children 22a7913bbeb5
line wrap: on
line diff
--- a/liboctave/idx-vector.h	Mon Feb 08 01:36:18 2010 -0500
+++ b/liboctave/idx-vector.h	Mon Feb 08 11:16:52 2010 +0100
@@ -89,6 +89,8 @@
 
     // Sorts, maybe uniqifies, and returns a clone object pointer.
     virtual idx_base_rep *sort_uniq_clone (bool uniq = false) = 0;
+    // Sorts, and returns a sorting permutation (aka Array::sort).
+    virtual idx_base_rep *sort_idx (Array<octave_idx_type>&) = 0;
 
     // Checks whether the index is colon or a range equivalent to colon.
     virtual bool is_colon_equiv (octave_idx_type) const
@@ -135,6 +137,8 @@
     idx_base_rep *sort_uniq_clone (bool = false) 
       { count++; return this; }
 
+    idx_base_rep *sort_idx (Array<octave_idx_type>&);
+
     bool is_colon_equiv (octave_idx_type) const
       { return true; }
 
@@ -183,6 +187,8 @@
 
     idx_base_rep *sort_uniq_clone (bool uniq = false);
 
+    idx_base_rep *sort_idx (Array<octave_idx_type>&);
+
     bool is_colon_equiv (octave_idx_type n) const
       { return start == 0 && step == 1 && len == n; }
 
@@ -240,6 +246,8 @@
     idx_base_rep *sort_uniq_clone (bool = false)
       { count++; return this; }
 
+    idx_base_rep *sort_idx (Array<octave_idx_type>&);
+
     bool is_colon_equiv (octave_idx_type n) const
       { return n == 1 && data == 0; }
 
@@ -305,6 +313,8 @@
 
     idx_base_rep *sort_uniq_clone (bool uniq = false);
 
+    idx_base_rep *sort_idx (Array<octave_idx_type>&);
+
     dim_vector orig_dimensions (void) const
       { return orig_dims; }
 
@@ -369,6 +379,8 @@
     idx_base_rep *sort_uniq_clone (bool = false) 
       { count++; return this; }
 
+    idx_base_rep *sort_idx (Array<octave_idx_type>&);
+
     dim_vector orig_dimensions (void) const
       { return orig_dims; }
 
@@ -560,6 +572,9 @@
   idx_vector sorted (bool uniq = false) const
     { return idx_vector (rep->sort_uniq_clone (uniq)); }
 
+  idx_vector sorted (Array<octave_idx_type>& sidx) const
+    { return idx_vector (rep->sort_idx (sidx)); }
+
   dim_vector orig_dimensions (void) const { return rep->orig_dimensions (); }
 
   octave_idx_type orig_rows (void) const