Jive reference manual
List of all members | Public Member Functions
jem::SliceFromTo Class Reference

A class for creating contiguous slices of array-like objects. More...

#include <jem/base/Slice.h>

Inheritance diagram for jem::SliceFromTo:
Inheritance graph

Public Member Functions

 SliceFromTo (int first, int last)
 Creates a SliceFromTo with a given begin index and end index. More...
 
- Public Member Functions inherited from jem::Slice
 Slice ()
 Creates an empty Slice. More...
 
 Slice (int first, int last, int stride=1)
 Constructs a Slice with a given begin index, end index and stride. More...
 
int first () const
 Returns the begin index. More...
 
int last () const
 Returns the end index. More...
 
int last (int ubound) const
 Returns a clipped end index. More...
 
int stride () const
 Returns the stride. More...
 

Additional Inherited Members

- Static Public Attributes inherited from jem::Slice
static const int MAX_INDEX
 The largest representable integer. More...
 

Detailed Description

A SliceFromTo is basically a Slice object with the following properties:

with first, last and stride denoting the begin index, end index and stride, respectively, and with n denoting the size of the array-like object from which a slice is to be taken. In other words, the end index of a SliceFromTo object may not be larger than the size of the array-like object. This property makes it possible for array-like objects to implement fast slice operators that do not have to truncate the end index to the size of the array-like object.

Note that the SliceFromTo will not be able check whether the end index is valid; it is your responsibility to create SliceFromTo objects with a valid end index.

A SliceFromTo is normally created by calling the global, non-member function slice().

See also
slice().

Constructor & Destructor Documentation

jem::SliceFromTo::SliceFromTo ( int  first,
int  last 
)

Creates a SliceFromTo with begin index first and end index last.

Parameters
first- the begin index.
last- the end index.
Precondition
first >= 0 &&
last >= first
Postcondition
this->first() == first &&
this->last() == last &&
this->stride() == 1