Vector and matrix picks allow arbitrary elements to be selected from a vector rather than just those patterns which can be selected by subscripting. A pick is created by calling member function pick(const RWIntVec&), where RWIntVec is a typedef for RWMathVec<int>. You can think of it as subscripting with an RWIntVec instead of an int:
// Set up picked elements: RWIntVec ipick("[3 4 8]"); RWMathVec<double> dv(10, 0, 2); // 0 2 4 6 8 10 12 14 16 18 RWMathVecPick<double> dvPick = dv.pick(ipick); cout << dvPick.length() << endl; // 3 cout << dvPick(0) << endl; // 6 cout << dvPick(2) << endl; // 16 |
Picks can also be used as lvalues:
dvPick = -1; cout << dv; // 0 2 4 -1 -1 10 12 14 -1 18 |
Unlike the subscripting operators, vector picks are not built into the classes, but implemented using a helper class with no public constructors. The result is that, unlike subscripting, picking does not create a new view. Because they are implemented using a helper class and their indexing is done using RWMathVec<int>s, picks are less efficient than subscripting.
Copyright © Rogue Wave Software, Inc. All Rights Reserved.
The Rogue Wave name and logo, and SourcePro, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.