diff src/ov-base.h @ 10670:654fbde5dceb

make cellfun's fast scalar collection mechanism public
author Jaroslav Hajek <highegg@gmail.com>
date Fri, 28 May 2010 12:28:06 +0200
parents 2f0fbfa4dd23
children 604e13a89c7f
line wrap: on
line diff
--- a/src/ov-base.h	Thu May 27 20:12:51 2010 -0700
+++ b/src/ov-base.h	Fri May 28 12:28:06 2010 +0200
@@ -714,6 +714,26 @@
 
   virtual octave_value map (unary_mapper_t) const;
 
+  // These are fast indexing & assignment shortcuts for extracting
+  // or inserting a single scalar from/to an array.
+
+  // Extract the n-th element, aka val(n). Result is undefined if val is not an
+  // array type or n is out of range. Never error.
+  virtual octave_value
+  fast_elem_extract (octave_idx_type n) const;
+
+  // Assign the n-th element, aka val(n) = x. Returns false if val is not an
+  // array type, x is not a matching scalar type, or n is out of range.
+  // Never error.
+  virtual bool
+  fast_elem_insert (octave_idx_type n, const octave_value& x);
+
+  // This is a helper for the above, to be overriden in scalar types.  The
+  // whole point is to handle the insertion efficiently with just *two* VM
+  // calls, which is basically the theoretical minimum.
+  virtual bool
+  fast_elem_insert_self (void *where, builtin_type_t btyp) const;
+
 protected:
 
   // This should only be called for derived types.