Simbody  3.5
SimTK::ArrayView_< T, X > Class Template Reference

This Array_ helper class is the base class for Array_, extending ArrayViewConst_ to add the ability to modify elements, but not the ability to change size or reallocate. More...

+ Inheritance diagram for SimTK::ArrayView_< T, X >:

Public Types

Typedefs

Types required of STL containers, plus index_type which is an extension, and packed_size_type which is an implementation detail.

typedef T value_type
 
typedef X index_type
 
typedef T * pointer
 
typedef const T * const_pointer
 
typedef T & reference
 
typedef const T & const_reference
 
typedef T * iterator
 
typedef const T * const_iterator
 
typedef std::reverse_iterator< iteratorreverse_iterator
 
typedef std::reverse_iterator< const_iteratorconst_reverse_iterator
 
typedef ArrayIndexTraits< X >::size_type size_type
 
typedef ArrayIndexTraits< X >::difference_type difference_type
 
typedef ArrayIndexPackType< size_type >::packed_size_type packed_size_type
 
- Public Types inherited from SimTK::ArrayViewConst_< T, X >
typedef T value_type
 The type of object stored in this container. More...
 
typedef X index_type
 The index type (an extension). More...
 
typedef T * pointer
 A writable pointer to a value_type. More...
 
typedef const T * const_pointer
 A const pointer to a value_type. More...
 
typedef T & reference
 A writable value_type reference. More...
 
typedef const T & const_reference
 A const value_type reference. More...
 
typedef T * iterator
 A writable iterator for this container (same as pointer here). More...
 
typedef const T * const_iterator
 A const iterator for this container (same as const_pointer here). More...
 
typedef std::reverse_iterator< iteratorreverse_iterator
 A writable reverse iterator for this container. More...
 
typedef std::reverse_iterator< const_iteratorconst_reverse_iterator
 A const reverse iterator for this container. More...
 
typedef ArrayIndexTraits< X >::size_type size_type
 An integral type suitable for all indices and sizes for this array. More...
 
typedef ArrayIndexTraits< X >::difference_type difference_type
 A signed integral type that can represent the difference between any two legitimate index values for this array. More...
 
typedef ArrayIndexPackType< size_type >::packed_size_type packed_size_type
 The integral type we actually use internally to store size_type values. More...
 

Public Member Functions

Construction, conversion, and destruction

Constructors here are limited to those that don't allocate new data, however they can reference writable data.

 ArrayView_ ()
 Default constructor allocates no heap space and is very fast. More...
 
 ArrayView_ (const ArrayView_ &src)
 Copy constructor is shallow. More...
 
 ArrayView_ (T *first, const T *last1)
 Construct from a range of writable memory. More...
 
template<class A >
 ArrayView_ (std::vector< T, A > &v)
 Construct to reference memory owned by a writable std::vector. More...
 
 operator const Array_< T, X > & () const
 Implicit conversion of const ArrayView_ to const Array_& (zero cost). More...
 
 operator Array_< T, X > & ()
 Implicit conversion of non-const ArrayView_ to Array_& (zero cost). More...
 
void disconnect ()
 Forward to base class disconnect() method – clears the handle without doing anything to the data. More...
 
 ~ArrayView_ ()
 The destructor just disconnects the array view handle from its data; see ArrayViewConst_<T,X>::disconnect() for more information. More...
 
Assignment

Assignment is permitted only if the source and destination are the same size.

The semantics here are different than for a resizeable Array_ object: here the meaning is elementwise assignment rather than destruction followed by copy construction. That is, if our elements are of type T, and the source elements are of type T2, we will use the operator of T that best matches the signature T::operator=(const T2&) to perform the assignments. When the source also has type T, this is just T's copy assignment operator. We never perform any element destruction or construction here.

ArrayView_operator= (const ArrayView_ &src)
 Copy assignment; source must be the same size as this array. More...
 
template<class T2 , class X2 >
ArrayView_operator= (const ArrayViewConst_< T2, X2 > &src)
 Assignment from any other array object is allowed as long as the number of elements matches and the types are assignment compatible. More...
 
template<class T2 , class X2 >
ArrayView_operator= (const ArrayView_< T2, X2 > &src)
 Assignment from any other array object is allowed as long as the number of elements matches and the types are assignment compatible. More...
 
template<class T2 , class X2 >
ArrayView_operator= (const Array_< T2, X2 > &src)
 Assignment from any other array object is allowed as long as the number of elements matches and the types are assignment compatible. More...
 
template<class T2 , class A2 >
ArrayView_operator= (const std::vector< T2, A2 > &src)
 Assignment from any std::vector object is allowed as long as the number of elements matches and the types are assignment compatible. More...
 
ArrayView_operator= (const T &fillValue)
 Fill assignment – all elements are set to fillValue. More...
 
ArrayView_fill (const T &fillValue)
 Assign the supplied fill value to each element of this array, using T's copy assignment operator for each element. More...
 
void assign (size_type n, const T &fillValue)
 This is the same as fill() but has the usual std::vector signature for compatibility; it will only work if the given number of elements is the same as this array's (fixed) size. More...
 
template<class T2 >
void assign (const T2 *first, const T2 *last1)
 Assign to this array to make it a copy of the elements in range [first,last1) given by ordinary pointers, provided that the range is the same size as the array. More...
 
template<class Iter >
void assign (const Iter &first, const Iter &last1)
 Assign to this array to make it a copy of the elements in range [first,last1) given by non-pointer iterators (the pointer case is handled with a specialized assign() variant). More...
 
Element access

These methods provide read and write access to individual elements that are currently present in the array; the ArrayViewConst_<T,X> base class provides the read-only (const) methods.

const T & operator[] (index_type i) const
 Select an element by its index, returning a const reference. More...
 
T & operator[] (index_type i)
 Select an element by its index, returning a writable (lvalue) reference. More...
 
const T & at (index_type i) const
 Same as operator[] but always range-checked, even in a Release build. More...
 
T & at (index_type i)
 Same as operator[] but always range-checked, even in a Release build. More...
 
const T & getElt (index_type i) const
 Same as the const form of operator[]; exists to provide a non-operator method for element access in case that's needed. More...
 
T & updElt (index_type i)
 Same as the non-const form of operator[]; exists to provide a non-operator method for element access in case that's needed. More...
 
const T & front () const
 Return a const reference to the first element in this array, which must not be empty. More...
 
T & front ()
 Return a writable reference to the first element in this array, which must not be empty. More...
 
const T & back () const
 Return a const reference to the last element in this array, which must not be empty. More...
 
T & back ()
 Return a writable reference to the last element in this array, which must not be empty. More...
 
ArrayView_ operator() (index_type index, size_type length)
 Select a contiguous subarray of the elements of this array and create another ArrayView_ that refers only to those element (without copying). More...
 
ArrayView_ updSubArray (index_type index, size_type length)
 Same as non-const operator()(index,length); exists to provide non-operator access to that functionality in case it is needed. More...
 
Iterators

These methods deal in iterators, which are STL generalized pointers.

For this class, iterators are just ordinary pointers to T, and you may depend on that. By necessity, reverse iterators can't be just pointers; however, they contain an ordinary iterator (i.e. a pointer) that can be obtained by calling the reverse iterator's base() method.

const T * cbegin () const
 Return a const pointer to the first element of this array if any, otherwise end(), which may be null (0) in that case but does not have to be. More...
 
const T * begin () const
 The const version of begin() is the same as cbegin(). More...
 
T * begin ()
 Return a writable pointer to the first element of this array if any, otherwise end(). More...
 
const T * cend () const
 Return a const pointer to what would be the element just after the last one in the array; this may be null (0) if there are no elements but doesn't have to be. More...
 
const T * end () const
 The const version of end() is the same as cend(). More...
 
T * end ()
 Return a writable pointer to what would be the element just after the last one in this array. More...
 
const_reverse_iterator crbegin () const
 Return a const reverse iterator pointing to the last element in the array or crend() if the array is empty. More...
 
const_reverse_iterator rbegin () const
 The const version of rbegin() is the same as crbegin(). More...
 
reverse_iterator rbegin ()
 Return a writable reverse iterator pointing to the last element in the array or rend() if the array is empty. More...
 
const_reverse_iterator crend () const
 Return the past-the-end reverse iterator that tests equal to a reverse iterator that has been incremented past the front of the array. More...
 
const_reverse_iterator rend () const
 The const version of rend() is the same as crend(). More...
 
reverse_iterator rend ()
 Return a writable past-the-end reverse iterator that tests equal to a reverse iterator that has been incremented past the front of the array. More...
 
const T * cdata () const
 Return a const pointer to the first element of the array, or possibly (but not necessarily) null (0) if the array is empty. More...
 
const T * data () const
 The const version of the data() method is identical to cdata(). More...
 
T * data ()
 Return a writable pointer to the first allocated element of the array, or a null pointer if no space is associated with the array. More...
 
- Public Member Functions inherited from SimTK::ArrayViewConst_< T, X >
 ArrayViewConst_ ()
 Default constructor allocates no heap space and is very fast. More...
 
 ArrayViewConst_ (const ArrayViewConst_ &src)
 Copy constructor is shallow; the constructed const array object will be referencing the original source data. More...
 
 ArrayViewConst_ (const T *first, const T *last1)
 Construct an ArrayViewConst_<T> by referencing (sharing) a given range of const data [first,last1), without copying that data. More...
 
template<class A >
 ArrayViewConst_ (const std::vector< T, A > &src)
 Construct a ArrayViewConst_<T> by referencing (sharing) the data in a const std::vector<T>, without copying the data; this is also an implicit conversion. More...
 
 operator const ArrayView_< T, X > & () const
 This is an implicit conversion to const ArrayView_<T,X>&, which is harmless since the const result won't permit writing on the elements. More...
 
 operator const Array_< T, X > & () const
 This is an implicit conversion to const Array_<T,X>&, which is harmless since the const result can't be used to write on or resize the data. More...
 
void disconnect ()
 Disconnect this array handle from any data to which it refers, restoring it to the condition it would be in if it had just been default-constructed. More...
 
 ~ArrayViewConst_ ()
 The destructor just disconnects the array view handle from its data; see disconnect() for more information. More...
 
size_type size () const
 Return the current number of elements stored in this array. More...
 
size_type max_size () const
 Return the maximum allowable size for this array. More...
 
bool empty () const
 Return true if there are no elements currently stored in this array. More...
 
size_type capacity () const
 Return the number of elements this array can currently hold without requiring reallocation. More...
 
size_type allocated () const
 Return the amount of heap space owned by this array; this is the same as capacity() for owner arrays but is zero for non-owners. More...
 
bool isOwner () const
 Does this array own the data to which it refers? If not, it can't be resized, and the destructor will not free any heap space nor call any element destructors. More...
 
const T & operator[] (index_type i) const
 Select an element by its index, returning a const reference. More...
 
const T & at (index_type i) const
 Same as operator[] but always range-checked, even in a Release build. More...
 
const T & getElt (index_type i) const
 Same as the const form of operator[]; exists to provide a non-operator method for element access in case that's needed. More...
 
const T & front () const
 Return a const reference to the first element in this array, which must not be empty (we'll check in a Debug build but not Release). More...
 
const T & back () const
 Return a const reference to the last element in this array, which must not be empty (we'll check in a Debug build but not Release). More...
 
ArrayViewConst_ operator() (index_type index, size_type length) const
 Select a contiguous subarray of the elements of this array and create another ArrayViewConst_ that refers only to those element (without copying). More...
 
ArrayViewConst_ getSubArray (index_type index, size_type length) const
 Same as const form of operator()(index,length); exists to provide non-operator access to that functionality in case it is needed. More...
 
const T * cbegin () const
 Return a const pointer to the first element of this array if any, otherwise cend(), which may be null (0) in that case but does not have to be. More...
 
const T * cend () const
 Return a const pointer to what would be the element just after the last one in the array; this may be null (0) if there are no elements but doesn't have to be. More...
 
const T * begin () const
 The const version of begin() is the same as cbegin(). More...
 
const T * end () const
 The const version of end() is the same as cend(). More...
 
const_reverse_iterator crbegin () const
 Return a const reverse iterator pointing to the last element in the array or crend() if the array is empty. More...
 
const_reverse_iterator crend () const
 Return the past-the-end reverse iterator that tests equal to a reverse iterator that has been incremented past the front of the array. More...
 
const_reverse_iterator rbegin () const
 The const version of rbegin() is the same as crbegin(). More...
 
const_reverse_iterator rend () const
 The const version of rend() is the same as crend(). More...
 
const T * cdata () const
 Return a const pointer to the first element of the array, or possibly (but not necessarily) null (0) if the array is empty. More...
 
const T * data () const
 The const version of the data() method is identical to cdata(). More...
 

Related Functions

(Note that these are not member functions.)

Array_<T> serialization and I/O

These methods are at namespace scope but are logically part of the Array classes.

These deal with reading and writing Arrays from and to streams, which places an additional requirement on the element type T: the element must support the same operation you are trying to do on the Array as a whole.

template<class T , class X >
bool readUnformatted (std::istream &in, ArrayView_< T, X > &v)
 Specialization of readUnformatted() for fixed-length ArrayView_<T,X>; reads whitespace-separated tokens until the expected number have been read. More...
 
template<class T , class X >
bool readFormatted (std::istream &in, ArrayView_< T, X > &v)
 Specialization of readFormatted() for fixed-length ArrayView_<T,X>; uses fillArrayViewFromStream() to consume an appropriately-formatted fixed-size array. More...
 
template<class T , class X >
static std::istream & fillArrayViewFromStream (std::istream &in, ArrayView_< T, X > &out)
 Read in a fixed number of elements from a stream into an ArrayView. More...
 
template<class T , class X >
std::istream & operator>> (std::istream &in, ArrayView_< T, X > &out)
 Read a (fixed size n) ArrayView_<T> from a stream as a sequence of space- or comma-separated values of type T, optionally delimited by parentheses, square brackets, or curly braces. More...
 

Size and capacity

These methods report the number of elements (size) or the amount of allocated heap space (capacity) or both but cannot be used to change size.

size_type size () const
 
size_type max_size () const
 
bool empty () const
 
size_type capacity () const
 
size_type allocated () const
 
bool isOwner () const
 

Detailed Description

template<class T, class X>
class SimTK::ArrayView_< T, X >

This Array_ helper class is the base class for Array_, extending ArrayViewConst_ to add the ability to modify elements, but not the ability to change size or reallocate.

Template Parameters
TThe type of object to be stored in this container.
XThe type to be used for indexing this container, with default unsigned (not size_t). Any integral type may be used, as well as user types that satisfy the requirements discussed with class ArrayIndexTraits.
See also
Array_, ArrayViewConst_, ArrayIndexTraits

Member Typedef Documentation

template<class T, class X>
typedef T SimTK::ArrayView_< T, X >::value_type
template<class T, class X>
typedef X SimTK::ArrayView_< T, X >::index_type
template<class T, class X>
typedef T* SimTK::ArrayView_< T, X >::pointer
template<class T, class X>
typedef const T* SimTK::ArrayView_< T, X >::const_pointer
template<class T, class X>
typedef T& SimTK::ArrayView_< T, X >::reference
template<class T, class X>
typedef const T& SimTK::ArrayView_< T, X >::const_reference
template<class T, class X>
typedef T* SimTK::ArrayView_< T, X >::iterator
template<class T, class X>
typedef const T* SimTK::ArrayView_< T, X >::const_iterator
template<class T, class X>
typedef std::reverse_iterator<iterator> SimTK::ArrayView_< T, X >::reverse_iterator
template<class T, class X>
typedef std::reverse_iterator<const_iterator> SimTK::ArrayView_< T, X >::const_reverse_iterator
template<class T, class X>
typedef ArrayIndexTraits<X>::size_type SimTK::ArrayView_< T, X >::size_type
template<class T, class X>
typedef ArrayIndexTraits<X>::difference_type SimTK::ArrayView_< T, X >::difference_type
template<class T, class X>
typedef ArrayIndexPackType<size_type>::packed_size_type SimTK::ArrayView_< T, X >::packed_size_type

Constructor & Destructor Documentation

template<class T, class X>
SimTK::ArrayView_< T, X >::ArrayView_ ( )
inline

Default constructor allocates no heap space and is very fast.

template<class T, class X>
SimTK::ArrayView_< T, X >::ArrayView_ ( const ArrayView_< T, X > &  src)
inline

Copy constructor is shallow.

template<class T, class X>
SimTK::ArrayView_< T, X >::ArrayView_ ( T *  first,
const T *  last1 
)
inline

Construct from a range of writable memory.

template<class T, class X>
template<class A >
SimTK::ArrayView_< T, X >::ArrayView_ ( std::vector< T, A > &  v)
inline

Construct to reference memory owned by a writable std::vector.

template<class T, class X>
SimTK::ArrayView_< T, X >::~ArrayView_ ( )
inline

The destructor just disconnects the array view handle from its data; see ArrayViewConst_<T,X>::disconnect() for more information.

Member Function Documentation

template<class T, class X>
SimTK::ArrayView_< T, X >::operator const Array_< T, X > & ( ) const
inline

Implicit conversion of const ArrayView_ to const Array_& (zero cost).

template<class T, class X>
SimTK::ArrayView_< T, X >::operator Array_< T, X > & ( )
inline

Implicit conversion of non-const ArrayView_ to Array_& (zero cost).

template<class T, class X>
void SimTK::ArrayView_< T, X >::disconnect ( )
inline

Forward to base class disconnect() method – clears the handle without doing anything to the data.

template<class T, class X>
ArrayView_& SimTK::ArrayView_< T, X >::operator= ( const ArrayView_< T, X > &  src)
inline

Copy assignment; source must be the same size as this array.

template<class T, class X>
template<class T2 , class X2 >
ArrayView_& SimTK::ArrayView_< T, X >::operator= ( const ArrayViewConst_< T2, X2 > &  src)
inline

Assignment from any other array object is allowed as long as the number of elements matches and the types are assignment compatible.

template<class T, class X>
template<class T2 , class X2 >
ArrayView_& SimTK::ArrayView_< T, X >::operator= ( const ArrayView_< T2, X2 > &  src)
inline

Assignment from any other array object is allowed as long as the number of elements matches and the types are assignment compatible.

template<class T, class X>
template<class T2 , class X2 >
ArrayView_& SimTK::ArrayView_< T, X >::operator= ( const Array_< T2, X2 > &  src)
inline

Assignment from any other array object is allowed as long as the number of elements matches and the types are assignment compatible.

template<class T, class X>
template<class T2 , class A2 >
ArrayView_& SimTK::ArrayView_< T, X >::operator= ( const std::vector< T2, A2 > &  src)
inline

Assignment from any std::vector object is allowed as long as the number of elements matches and the types are assignment compatible.

template<class T, class X>
ArrayView_& SimTK::ArrayView_< T, X >::operator= ( const T &  fillValue)
inline

Fill assignment – all elements are set to fillValue.

See also
fill()
template<class T, class X>
ArrayView_& SimTK::ArrayView_< T, X >::fill ( const T &  fillValue)
inline

Assign the supplied fill value to each element of this array, using T's copy assignment operator for each element.

Note that this also serves to allow fill from an object whose type T2 is different from T, as long as there is a constructor T(T2) that works since that can be invoked (implicitly or explicitly) to convert the T2 object to type T prior to the call.

template<class T, class X>
void SimTK::ArrayView_< T, X >::assign ( size_type  n,
const T &  fillValue 
)
inline

This is the same as fill() but has the usual std::vector signature for compatibility; it will only work if the given number of elements is the same as this array's (fixed) size.

template<class T, class X>
template<class T2 >
void SimTK::ArrayView_< T, X >::assign ( const T2 *  first,
const T2 *  last1 
)
inline

Assign to this array to make it a copy of the elements in range [first,last1) given by ordinary pointers, provided that the range is the same size as the array.

It is not allowed for the source range to include any of the elements currently in the array. The source elements can be of a type T2 that may be the same or different than this array's element type T as long as there is a T=T2 assignment operator that works. Note that although the source arguments are pointers, those may be iterators for some container depending on implementation details of the container. Specifically, any ArrayViewConst_, ArrayView_, or Array_ iterator is an ordinary pointer.

Parameters
[in]firstA pointer to the first element to be copied.
[in]last1A pointer to the element one past the last element to be copied.
Precondition
last1-first == size()
Complexity:
The T=T2 assignment operator will be called exactly size() times.
template<class T, class X>
template<class Iter >
void SimTK::ArrayView_< T, X >::assign ( const Iter &  first,
const Iter &  last1 
)
inline

Assign to this array to make it a copy of the elements in range [first,last1) given by non-pointer iterators (the pointer case is handled with a specialized assign() variant).

It is not allowed for this range to include any of the elements currently in the array. The source elements can be of a type T2 that may be the same or different than this array's element type T as long as there is a T=T2 operator that works.

The source must have the same number of elements as the current (fixed) size of this ArrayView. For input_iterators we'll be happy if we get enough elements and won't insist that the input stream is empty after that. For forward_ and bidirectional_iterators we'll copy the elements and complain at the end if there are too few or too many. For random_access_iterators we'll check in advance since we can do that fast.

Parameters
[in]firstAn iterator pointing to the first element to be copied.
[in]last1An iterator pointing to the element one past the last element to be copied.
Remarks
This variant of assign() will not be called when the iterators are forward iterators from ArrayViewConst_, ArrayView_, or Array_ objects since those are ordinary pointers.
Precondition
last1 is reachable from first
distance(first,last1)==size()
Complexity:
The T=T2 assignment operator will be called exactly size() times.
template<class T, class X>
const T& SimTK::ArrayView_< T, X >::operator[] ( index_type  i) const
inline

Select an element by its index, returning a const reference.

Note that only a value of the array's templatized index type is allowed (default is unsigned). This will be range-checked in a Debug build but not in Release.

Precondition
0 <= i < size()
Complexity:
Constant time.
template<class T, class X>
T& SimTK::ArrayView_< T, X >::operator[] ( index_type  i)
inline

Select an element by its index, returning a writable (lvalue) reference.

Note that only a value of the Array's templatized index type is allowed (default is unsigned). This will be range-checked in a Debug build but not in Release.

Precondition
0 <= i < size()
Complexity:
Constant time.
template<class T, class X>
const T& SimTK::ArrayView_< T, X >::at ( index_type  i) const
inline

Same as operator[] but always range-checked, even in a Release build.

Precondition
0 <= i < size()
Complexity:
Constant time.
template<class T, class X>
T& SimTK::ArrayView_< T, X >::at ( index_type  i)
inline

Same as operator[] but always range-checked, even in a Release build.

Precondition
0 <= i < size()
Complexity:
Constant time.
template<class T, class X>
const T& SimTK::ArrayView_< T, X >::getElt ( index_type  i) const
inline

Same as the const form of operator[]; exists to provide a non-operator method for element access in case that's needed.

template<class T, class X>
T& SimTK::ArrayView_< T, X >::updElt ( index_type  i)
inline

Same as the non-const form of operator[]; exists to provide a non-operator method for element access in case that's needed.

template<class T, class X>
const T& SimTK::ArrayView_< T, X >::front ( ) const
inline

Return a const reference to the first element in this array, which must not be empty.

Precondition
The array is not empty.
Complexity:
Constant time.
template<class T, class X>
T& SimTK::ArrayView_< T, X >::front ( )
inline

Return a writable reference to the first element in this array, which must not be empty.

Precondition
The array is not empty.
Complexity:
Constant time.
template<class T, class X>
const T& SimTK::ArrayView_< T, X >::back ( ) const
inline

Return a const reference to the last element in this array, which must not be empty.

Precondition
The array is not empty.
Complexity:
Constant time.
template<class T, class X>
T& SimTK::ArrayView_< T, X >::back ( )
inline

Return a writable reference to the last element in this array, which must not be empty.

Precondition
The array is not empty.
Complexity:
Constant time.
template<class T, class X>
ArrayView_ SimTK::ArrayView_< T, X >::operator() ( index_type  index,
size_type  length 
)
inline

Select a contiguous subarray of the elements of this array and create another ArrayView_ that refers only to those element (without copying).

Parameters
[in]indexThe index of the first element to be included in the subarray; this can be one past the end of the array if length is zero.
[in]lengthThe length of the subarray to be produced.
Returns
A new ArrayView_<T,X> object referencing the original data.
Note
If length==0 the returned array will be in a default-constructed, all-zero and null state with no connection to the original data.
Precondition
index >= 0, length >= 0
index + length <= size()
We'll validate preconditions in Debug builds but not Release.
Complexity:
Dirt cheap; no element construction or destruction or heap allocation is required.
template<class T, class X>
ArrayView_ SimTK::ArrayView_< T, X >::updSubArray ( index_type  index,
size_type  length 
)
inline

Same as non-const operator()(index,length); exists to provide non-operator access to that functionality in case it is needed.

template<class T, class X>
const T* SimTK::ArrayView_< T, X >::cbegin ( ) const
inline

Return a const pointer to the first element of this array if any, otherwise end(), which may be null (0) in that case but does not have to be.

This method is from the proposed C++0x standard; there is also an overloaded begin() from the original standard that returns a const pointer.

template<class T, class X>
const T* SimTK::ArrayView_< T, X >::begin ( ) const
inline

The const version of begin() is the same as cbegin().

template<class T, class X>
T* SimTK::ArrayView_< T, X >::begin ( )
inline

Return a writable pointer to the first element of this array if any, otherwise end().

If the array is empty, this may return null (0) but does not have to – the only thing you can be sure of is that begin() == end() for an empty array.

template<class T, class X>
const T* SimTK::ArrayView_< T, X >::cend ( ) const
inline

Return a const pointer to what would be the element just after the last one in the array; this may be null (0) if there are no elements but doesn't have to be.

This method is from the proposed C++0x standard; there is also an overloaded end() from the original standard that returns a const pointer.

template<class T, class X>
const T* SimTK::ArrayView_< T, X >::end ( ) const
inline

The const version of end() is the same as cend().

template<class T, class X>
T* SimTK::ArrayView_< T, X >::end ( )
inline

Return a writable pointer to what would be the element just after the last one in this array.

If the array is empty, this may return null (0) but does not have to – the only thing you can be sure of is that begin()==end() for an empty array.

template<class T, class X>
const_reverse_iterator SimTK::ArrayView_< T, X >::crbegin ( ) const
inline

Return a const reverse iterator pointing to the last element in the array or crend() if the array is empty.

template<class T, class X>
const_reverse_iterator SimTK::ArrayView_< T, X >::rbegin ( ) const
inline

The const version of rbegin() is the same as crbegin().

template<class T, class X>
reverse_iterator SimTK::ArrayView_< T, X >::rbegin ( )
inline

Return a writable reverse iterator pointing to the last element in the array or rend() if the array is empty.

template<class T, class X>
const_reverse_iterator SimTK::ArrayView_< T, X >::crend ( ) const
inline

Return the past-the-end reverse iterator that tests equal to a reverse iterator that has been incremented past the front of the array.

You cannot dereference this iterator.

template<class T, class X>
const_reverse_iterator SimTK::ArrayView_< T, X >::rend ( ) const
inline

The const version of rend() is the same as crend().

template<class T, class X>
reverse_iterator SimTK::ArrayView_< T, X >::rend ( )
inline

Return a writable past-the-end reverse iterator that tests equal to a reverse iterator that has been incremented past the front of the array.

You cannot dereference this iterator.

template<class T, class X>
const T* SimTK::ArrayView_< T, X >::cdata ( ) const
inline

Return a const pointer to the first element of the array, or possibly (but not necessarily) null (0) if the array is empty.

Note
cdata() does not appear to be in the C++0x standard although it would seem obvious in view of the cbegin() and cend() methods that had to be added. The C++0x overloaded const data() method is also available.
template<class T, class X>
const T* SimTK::ArrayView_< T, X >::data ( ) const
inline

The const version of the data() method is identical to cdata().

Note
This method is from the proposed C++0x std::vector.
template<class T, class X>
T* SimTK::ArrayView_< T, X >::data ( )
inline

Return a writable pointer to the first allocated element of the array, or a null pointer if no space is associated with the array.

Note
This method is from the proposed C++0x std::vector.
template<class T, class X>
size_type SimTK::ArrayView_< T, X >::size ( ) const
inline
template<class T, class X>
size_type SimTK::ArrayView_< T, X >::max_size ( ) const
inline
template<class T, class X>
bool SimTK::ArrayView_< T, X >::empty ( ) const
inline
template<class T, class X>
size_type SimTK::ArrayView_< T, X >::capacity ( ) const
inline
template<class T, class X>
size_type SimTK::ArrayView_< T, X >::allocated ( ) const
inline
template<class T, class X>
bool SimTK::ArrayView_< T, X >::isOwner ( ) const
inline

Friends And Related Function Documentation

template<class T , class X >
bool readUnformatted ( std::istream &  in,
ArrayView_< T, X > &  v 
)
related

Specialization of readUnformatted() for fixed-length ArrayView_<T,X>; reads whitespace-separated tokens until the expected number have been read.

If fewer are available we fail.

template<class T , class X >
bool readFormatted ( std::istream &  in,
ArrayView_< T, X > &  v 
)
related

Specialization of readFormatted() for fixed-length ArrayView_<T,X>; uses fillArrayViewFromStream() to consume an appropriately-formatted fixed-size array.

See also
fillArrayViewFromStream() for details
template<class T , class X >
static std::istream & fillArrayViewFromStream ( std::istream &  in,
ArrayView_< T, X > &  out 
)
related

Read in a fixed number of elements from a stream into an ArrayView.

See fillArrayFromStream() for more information; this works the same way.

See also
fillArrayFromStream()
template<class T , class X >
std::istream & operator>> ( std::istream &  in,
ArrayView_< T, X > &  out 
)
related

Read a (fixed size n) ArrayView_<T> from a stream as a sequence of space- or comma-separated values of type T, optionally delimited by parentheses, square brackets, or curly braces.

If there are no delimiters then we will read size() values and then stop. Otherwise, there must be exactly size() values within the brackets. Each element is read in with its own operator ">>" so this won't work if no such operator is defined for type T.


The documentation for this class was generated from the following file: