@@ -308,6 +308,14 @@ class NumericVector : public ReferenceCountedObject<NumericVector<T> >
308
308
*/
309
309
virtual T el (const unsigned int i) const { return (*this )(i); }
310
310
311
+ /* *
312
+ * Access multiple components at once. \p values will be resized,
313
+ * if necessary, and filled. The default implementation calls \p
314
+ * operator() for each index, but some implementations may supply
315
+ * faster methods here.
316
+ */
317
+ virtual void get (const std::vector<unsigned int >& index, std::vector<T>& values) const ;
318
+
311
319
/* *
312
320
* Addition operator.
313
321
* Fast equivalent to \p U.add(1, V).
@@ -558,7 +566,7 @@ class NumericVector : public ReferenceCountedObject<NumericVector<T> >
558
566
* enough indirection in subclasses to make this an O(1) header-swap
559
567
* operation.
560
568
*/
561
- virtual void swap (NumericVector<T> &v) = 0 ;
569
+ virtual void swap (NumericVector<T> &v);
562
570
563
571
protected:
564
572
@@ -693,6 +701,20 @@ void NumericVector<T>::clear ()
693
701
_is_closed = false ;
694
702
_is_initialized = false ;
695
703
}
704
+
705
+
706
+
707
+ template <typename T>
708
+ inline
709
+ void NumericVector<T>::get(const std::vector<unsigned int >& index, std::vector<T>& values) const
710
+ {
711
+ const unsigned int num = index.size ();
712
+ values.resize (num);
713
+ for (unsigned int i=0 ; i<num; i++)
714
+ {
715
+ values[i] = (*this )(index[i]);
716
+ }
717
+ }
696
718
697
719
698
720
@@ -775,4 +797,15 @@ void NumericVector<T>::print_global(std::ostream& os) const
775
797
776
798
777
799
800
+ template <typename T>
801
+ inline
802
+ void NumericVector<T>::swap (NumericVector<T> &v)
803
+ {
804
+ std::swap (_is_closed, v._is_closed );
805
+ std::swap (_is_initialized, v._is_initialized );
806
+ std::swap (_type, v._type );
807
+ }
808
+
809
+
810
+
778
811
#endif // #ifdef __numeric_vector_h__
0 commit comments