SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches

Represents an index that can be used for subscripting vectors, matrices, and arrays. More...

#include <rw/rwslice.h>

Inheritance diagram for RWRange:
RWSlice

Public Member Functions

 RWRange (int begin, int end)
 
 RWRange (int begin, int end, int stride)
 
- Public Member Functions inherited from RWSlice
 RWSlice (const char *s)
 
 RWSlice (int begin, int length)
 
 RWSlice (int begin, int length, int stride)
 

Additional Inherited Members

Detailed Description

An RWRange object is an index which can be used for subscripting vectors, matrices, and arrays. By subscripting with RWRange objects, you create views of selected elements. These new views are vectors, matrices, or arrays in their own right, rather than simply helper classes. This means that a view created with subscripting can be used as an rvalue, an lvalue, or kept as an object for use later.

The class RWRange is derived from RWSlice. It can be used to initialize an RWSlice object as follows:

RWSlice s = RWRange(b, e);
Represents an index that can be used for subscripting vectors, matrices, and arrays.
Definition rwslice.h:232
Represents an index that can be used for subscripting vectors, matrices, and arrays.
Definition rwslice.h:105
Synopsis
#include <rw/math/mathvec.h>
cout << x(RWRange(3, 5)); // print elements 3,4,5
A templatized vector class.
Definition mathvec.h:667
Example
#include <rw/math/genmat.h>
#include <iostream.h>
int main() {
RWGenMat<int> A(6, 6);
RWRange I(0, 2);
RWRange J(3, 5);
A(I, I) = 1;
A(I, J) = 2;
A(J, I) = 3;
A(J, J) = 4;
cout << A << endl;
}
A templatized general matrix class.
Definition genmat.h:741

Program output:

6x6
[
1 1 1 2 2 2
1 1 1 2 2 2
1 1 1 2 2 2
3 3 3 4 4 4
3 3 3 4 4 4
3 3 3 4 4 4
]
See also
RWSlice, RWToEnd, RWMathVec::operator()(), RWGenMat::operator()(), RWMathArray::operator()()

Constructor & Destructor Documentation

◆ RWRange() [1/2]

RWRange::RWRange ( int begin,
int end )
inline

Constructs an object which indexes starting at element begin and ending with element end. If end is smaller than begin, the elements are accessed in reverse order.

◆ RWRange() [2/2]

RWRange::RWRange ( int begin,
int end,
int stride )
inline

Constructs an object which indexes starting at element begin and ending with element end. If end is smaller than begin, the elements are accessed in reverse order. The parameter stride gives the increment between selected elements; it must always be greater than 0.

Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.