Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
PxStrideIterator< T > Class Template Reference

Iterator class for iterating over arrays of data that may be interleaved with other data. More...

#include <PxStrideIterator.h>

Inheritance diagram for PxStrideIterator< T >:
Inheritance graph
[legend]
Collaboration diagram for PxStrideIterator< T >:
Collaboration graph
[legend]

Public Member Functions

PX_INLINE PxStrideIterator (T *ptr=NULL, PxU32 stride=sizeof(T))
 Constructor. More...
 
PX_INLINE PxStrideIterator (const PxStrideIterator< typename StripConst< T >::Type > &strideIterator)
 Copy constructor. More...
 
PX_INLINE T * ptr () const
 Get pointer to element. More...
 
PX_INLINE PxU32 stride () const
 Get stride. More...
 
PX_INLINE T & operator* () const
 Indirection operator. More...
 
PX_INLINE T * operator-> () const
 Dereferencing operator. More...
 
PX_INLINE T & operator[] (unsigned int i) const
 Indexing operator. More...
 
PX_DEPRECATED PX_INLINE T & operator[] (int i) const
 Indexing operator. More...
 
PX_INLINE PxStrideIteratoroperator++ ()
 Pre-increment operator. More...
 
PX_INLINE PxStrideIterator operator++ (int)
 Post-increment operator. More...
 
PX_INLINE PxStrideIteratoroperator-- ()
 Pre-decrement operator. More...
 
PX_INLINE PxStrideIterator operator-- (int)
 Post-decrement operator. More...
 
PX_INLINE PxStrideIterator operator+ (unsigned int i) const
 Addition operator. More...
 
PX_DEPRECATED PX_INLINE
PxStrideIterator 
operator+ (int i) const
 Addition operator. More...
 
PX_INLINE PxStrideIterator operator- (unsigned int i) const
 Subtraction operator. More...
 
PX_DEPRECATED PX_INLINE
PxStrideIterator 
operator- (int i) const
 Subtraction operator. More...
 
PX_INLINE PxStrideIteratoroperator+= (unsigned int i)
 Addition compound assignment operator. More...
 
PX_DEPRECATED PX_INLINE
PxStrideIterator
operator+= (int i)
 Addition compound assignment operator. More...
 
PX_INLINE PxStrideIteratoroperator-= (unsigned int i)
 Subtraction compound assignment operator. More...
 
PX_DEPRECATED PX_INLINE
PxStrideIterator
operator-= (int i)
 Subtraction compound assignment operator. More...
 
PX_INLINE int operator- (const PxStrideIterator &other) const
 Iterator difference. More...
 
PX_INLINE bool operator== (const PxStrideIterator &other) const
 Equality operator. More...
 
PX_INLINE bool operator!= (const PxStrideIterator &other) const
 Inequality operator. More...
 
PX_INLINE bool operator< (const PxStrideIterator &other) const
 Less than operator. More...
 
PX_INLINE bool operator> (const PxStrideIterator &other) const
 Greater than operator. More...
 
PX_INLINE bool operator<= (const PxStrideIterator &other) const
 Less or equal than operator. More...
 
PX_INLINE bool operator>= (const PxStrideIterator &other) const
 Greater or equal than operator. More...
 

Private Member Functions

PX_INLINE bool isCompatible (const PxStrideIterator &other) const
 

Static Private Member Functions

static PX_INLINE T * byteAdd (T *ptr, PxU32 bytes)
 
static PX_INLINE T * byteSub (T *ptr, PxU32 bytes)
 

Private Attributes

T * mPtr
 
PxU32 mStride
 

Detailed Description

template<typename T>
class PxStrideIterator< T >

Iterator class for iterating over arrays of data that may be interleaved with other data.

This class is used for iterating over arrays of elements that may have a larger element to element offset, called the stride, than the size of the element itself (non-contiguous).

The template parameter T denotes the type of the element accessed. The stride itself is stored as a member field so multiple instances of a PxStrideIterator class can have different strides. This is useful for cases were the stride depends on runtime configuration.

The stride iterator can be used for index based access, e.g.:

PxStrideIterator<PxVec3> strideArray(...);
for (unsigned i = 0; i < 10; ++i)
{
PxVec3& vec = strideArray[i];
...
}

or iteration by increment, e.g.:

PxStrideIterator<PxVec3> strideBegin(...);
PxStrideIterator<PxVec3> strideEnd(strideBegin + 10);
for (PxStrideIterator<PxVec3> it = strideBegin; it < strideEnd; ++it)
{
PxVec3& vec = *it;
...
}

Two special cases:

Constructor & Destructor Documentation

template<typename T>
PX_INLINE PxStrideIterator< T >::PxStrideIterator ( T *  ptr = NULL,
PxU32  stride = sizeof(T) 
)
inlineexplicit

Constructor.

Optionally takes a pointer to an element and a stride.

Parameters
[in]ptrpointer to element, defaults to NULL.
[in]stridestride for accessing consecutive elements, defaults to the size of one element.
template<typename T>
PX_INLINE PxStrideIterator< T >::PxStrideIterator ( const PxStrideIterator< typename StripConst< T >::Type > &  strideIterator)
inline

Copy constructor.

Parameters
[in]strideIteratorPxStrideIterator to be copied.

Member Function Documentation

template<typename T>
static PX_INLINE T* PxStrideIterator< T >::byteAdd ( T *  ptr,
PxU32  bytes 
)
inlinestaticprivate
template<typename T>
static PX_INLINE T* PxStrideIterator< T >::byteSub ( T *  ptr,
PxU32  bytes 
)
inlinestaticprivate
template<typename T>
PX_INLINE bool PxStrideIterator< T >::isCompatible ( const PxStrideIterator< T > &  other) const
inlineprivate
template<typename T>
PX_INLINE bool PxStrideIterator< T >::operator!= ( const PxStrideIterator< T > &  other) const
inline

Inequality operator.

template<typename T>
PX_INLINE T& PxStrideIterator< T >::operator* ( ) const
inline

Indirection operator.

template<typename T>
PX_INLINE PxStrideIterator PxStrideIterator< T >::operator+ ( unsigned int  i) const
inline

Addition operator.

template<typename T>
PX_DEPRECATED PX_INLINE PxStrideIterator PxStrideIterator< T >::operator+ ( int  i) const
inline

Addition operator.

template<typename T>
PX_INLINE PxStrideIterator& PxStrideIterator< T >::operator++ ( )
inline

Pre-increment operator.

template<typename T>
PX_INLINE PxStrideIterator PxStrideIterator< T >::operator++ ( int  )
inline

Post-increment operator.

template<typename T>
PX_INLINE PxStrideIterator& PxStrideIterator< T >::operator+= ( unsigned int  i)
inline

Addition compound assignment operator.

template<typename T>
PX_DEPRECATED PX_INLINE PxStrideIterator& PxStrideIterator< T >::operator+= ( int  i)
inline

Addition compound assignment operator.

template<typename T>
PX_INLINE PxStrideIterator PxStrideIterator< T >::operator- ( unsigned int  i) const
inline

Subtraction operator.

template<typename T>
PX_DEPRECATED PX_INLINE PxStrideIterator PxStrideIterator< T >::operator- ( int  i) const
inline

Subtraction operator.

template<typename T>
PX_INLINE int PxStrideIterator< T >::operator- ( const PxStrideIterator< T > &  other) const
inline

Iterator difference.

template<typename T>
PX_INLINE PxStrideIterator& PxStrideIterator< T >::operator-- ( )
inline

Pre-decrement operator.

template<typename T>
PX_INLINE PxStrideIterator PxStrideIterator< T >::operator-- ( int  )
inline

Post-decrement operator.

template<typename T>
PX_INLINE PxStrideIterator& PxStrideIterator< T >::operator-= ( unsigned int  i)
inline

Subtraction compound assignment operator.

template<typename T>
PX_DEPRECATED PX_INLINE PxStrideIterator& PxStrideIterator< T >::operator-= ( int  i)
inline

Subtraction compound assignment operator.

template<typename T>
PX_INLINE T* PxStrideIterator< T >::operator-> ( ) const
inline

Dereferencing operator.

template<typename T>
PX_INLINE bool PxStrideIterator< T >::operator< ( const PxStrideIterator< T > &  other) const
inline

Less than operator.

template<typename T>
PX_INLINE bool PxStrideIterator< T >::operator<= ( const PxStrideIterator< T > &  other) const
inline

Less or equal than operator.

template<typename T>
PX_INLINE bool PxStrideIterator< T >::operator== ( const PxStrideIterator< T > &  other) const
inline

Equality operator.

template<typename T>
PX_INLINE bool PxStrideIterator< T >::operator> ( const PxStrideIterator< T > &  other) const
inline

Greater than operator.

template<typename T>
PX_INLINE bool PxStrideIterator< T >::operator>= ( const PxStrideIterator< T > &  other) const
inline

Greater or equal than operator.

template<typename T>
PX_INLINE T& PxStrideIterator< T >::operator[] ( unsigned int  i) const
inline

Indexing operator.

template<typename T>
PX_DEPRECATED PX_INLINE T& PxStrideIterator< T >::operator[] ( int  i) const
inline

Indexing operator.

template<typename T>
PX_INLINE T* PxStrideIterator< T >::ptr ( ) const
inline

Get pointer to element.

template<typename T>
PX_INLINE PxU32 PxStrideIterator< T >::stride ( ) const
inline

Member Data Documentation

template<typename T>
T* PxStrideIterator< T >::mPtr
private
template<typename T>
PxU32 PxStrideIterator< T >::mStride
private

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


Copyright © 2008-2015 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. www.nvidia.com