dlr::common::StridedPointer< Type > Class Template Reference

The StridedPointer class permits convenient iterator-style access to regularly spaced elements within a C-style array. More...

#include <stridedPointer.h>

List of all members.

Public Member Functions

 StridedPointer ()
 The default constructor creates a null pointer with stride == 1.
 StridedPointer (Type *pointer)
 This constructor creates a StridedPointer which points to the same memory as the argument, and has stride == 1.
 StridedPointer (Type *pointer, int stride)
 This constructor creates a StridedPointer which has the same value as the argument, but has the specified stride.
 StridedPointer (const StridedPointer< Type > &source)
 This is the copy constructor.
 ~StridedPointer ()
 Destroys the StridedPointer instance.
Type & operator* ()
 The dereference operator permits reading and writing the value to which this StridedPointer instance currently points.
Type * operator-> ()
 The access operator allows you to access the member functions and member variables of the value to which this StridedPointer instance currently points, just as you would with a normal pointer.
StridedPointer< Type > & operator++ ()
 The pre-increment operator actually adds the value of stride (which was set at construction time) to *this.
StridedPointer< Type > operator++ (int)
 The post-increment operator is just like the pre-increment operator, above, but returns a copy of the StridedPointer which has not been incremented.
StridedPointer< Type > & operator-- ()
 The pre-decrement operator is just like the pre-increment operator, above, but increments instead of decrements.
StridedPointer< Type > operator-- (int)
 The post-decrement operator is just like the post-increment operator, above, but increments instead of decrements.
StridedPointer< Type > operator+ (ptrdiff_t offset)
 This operator has the same effect as incrementing a copy of *this offset times, but runs in O(1) time.
StridedPointer< Type > operator- (ptrdiff_t offset)
 This operator works just like operator+() above, but decreases the StridedPointer value instead of increasing it.
ptrdiff_t operator- (const StridedPointer< Type > &other)
 This operator attempts to return a value N so that *(*this) == *(other + N).
StridedPointer< Type > & operator+= (ptrdiff_t offset)
 This operator has the same effect as incrementing *this offset times, but runs in O(1) time.
StridedPointer< Type > & operator-= (ptrdiff_t offset)
 This operator has the same effect as decrementing *this offset times, but runs in O(1) time.
bool operator== (const StridedPointer< Type > &other) const
 This operator returns true if its argument references the same memory location as *this, false otherwise.
bool operator!= (const StridedPointer< Type > &other) const
 This operator returns false if its argument references the same memory location as *this, true otherwise.
bool operator< (const StridedPointer< Type > &other) const
 This operator return true if the address of the memory location referenced by *this is less than the address of the memory location referenced by other, false otherwise.
bool operator> (const StridedPointer< Type > &other) const
 This operator return true if the address of the memory location referenced by *this is greater than the address of the memory location referenced by other, false otherwise.
bool operator<= (const StridedPointer< Type > &other) const
 This operator return true if the address of the memory location referenced by *this is less than or equal to the address of the memory location referenced by other, false otherwise.
bool operator>= (const StridedPointer< Type > &other) const
 This operator return true if the address of the memory location referenced by *this is greater than or equal to the address of the memory location referenced by other, false otherwise.
StridedPointer< Type > & operator= (const StridedPointer< Type > &source)
 The assignment operator copies both address and stride from its argument.


Detailed Description

template<class Type>
class dlr::common::StridedPointer< Type >

The StridedPointer class permits convenient iterator-style access to regularly spaced elements within a C-style array.

That is, a StridedPointer instance with stride == 1 acts a lot like an ordinary pointer, while a StridedPointer instance with stride == 2 "sees" only every other element of the array, and so on.

Definition at line 32 of file stridedPointer.h.


Constructor & Destructor Documentation

template<class Type>
dlr::common::StridedPointer< Type >::StridedPointer (  )  [inline]

The default constructor creates a null pointer with stride == 1.

Definition at line 40 of file stridedPointer.h.

template<class Type>
dlr::common::StridedPointer< Type >::StridedPointer ( Type *  pointer  )  [inline]

This constructor creates a StridedPointer which points to the same memory as the argument, and has stride == 1.

Parameters:
pointer The pointer from which to take the initial value of *this.

Definition at line 49 of file stridedPointer.h.

template<class Type>
dlr::common::StridedPointer< Type >::StridedPointer ( Type *  pointer,
int  stride 
) [inline]

This constructor creates a StridedPointer which has the same value as the argument, but has the specified stride.

Parameters:
pointer The pointer from which to take the initial value of *this.
stride The StridedPointer instance will be able to access only every stride'th element in the array.

Definition at line 60 of file stridedPointer.h.

template<class Type>
dlr::common::StridedPointer< Type >::StridedPointer ( const StridedPointer< Type > &  source  )  [inline]

This is the copy constructor.

It copies both address and stride from its argument.

Parameters:
source The StridedPointer instance to be copied.

Definition at line 69 of file stridedPointer.h.

template<class Type>
dlr::common::StridedPointer< Type >::~StridedPointer (  )  [inline]

Destroys the StridedPointer instance.

Definition at line 75 of file stridedPointer.h.


Member Function Documentation

template<class Type>
bool dlr::common::StridedPointer< Type >::operator!= ( const StridedPointer< Type > &  other  )  const [inline]

This operator returns false if its argument references the same memory location as *this, true otherwise.

Parameters:
other A StridedPointer instance to be compared with *this.
Returns:
false if other references same memory location as *this, true otherwise.

Definition at line 244 of file stridedPointer.h.

References dlr::common::StridedPointer< Type >::m_pointer.

template<class Type>
Type& dlr::common::StridedPointer< Type >::operator* (  )  [inline]

The dereference operator permits reading and writing the value to which this StridedPointer instance currently points.

For example, you might write:

StridedPointer<char> ptr(...); char ch = *ptr;

just as you would with a native pointer type.

Returns:
Reference to the value to which this StridedPointer instance currently points.

Definition at line 91 of file stridedPointer.h.

template<class Type>
StridedPointer<Type> dlr::common::StridedPointer< Type >::operator+ ( ptrdiff_t  offset  )  [inline]

This operator has the same effect as incrementing a copy of *this offset times, but runs in O(1) time.

That is, a call to operator+() returns a StridedPointer instance which references a place in memory which is (stride * offset) items advance from value referenced by *this.

Parameters:
offset This argument specifies how many steps to advance.
Returns:
A copy of *this which references the new location.

Definition at line 161 of file stridedPointer.h.

template<class Type>
StridedPointer<Type> dlr::common::StridedPointer< Type >::operator++ ( int   )  [inline]

The post-increment operator is just like the pre-increment operator, above, but returns a copy of the StridedPointer which has not been incremented.

Returns:
An un-incremented copy of *this.

Definition at line 124 of file stridedPointer.h.

template<class Type>
StridedPointer<Type>& dlr::common::StridedPointer< Type >::operator++ (  )  [inline]

The pre-increment operator actually adds the value of stride (which was set at construction time) to *this.

That is, if the value of stride is N, then incrementing a StridedPointer instance makes it point to an array element N spaces away.

Returns:
A Reference to the incremented StridedPointer instance.

Definition at line 115 of file stridedPointer.h.

template<class Type>
StridedPointer<Type>& dlr::common::StridedPointer< Type >::operator+= ( ptrdiff_t  offset  )  [inline]

This operator has the same effect as incrementing *this offset times, but runs in O(1) time.

Parameters:
offset This argument specifies how many steps to advance the StridedPointer.
Returns:
A reference to *this.

Definition at line 206 of file stridedPointer.h.

template<class Type>
ptrdiff_t dlr::common::StridedPointer< Type >::operator- ( const StridedPointer< Type > &  other  )  [inline]

This operator attempts to return a value N so that *(*this) == *(other + N).

Note that this value is meaningless if the two StridedPointer instances have different stride values. Note also that if stride is not equal to 1, it is very possible to have two StridedPointer instances which are "out of phase" so that there is no value of N which satisfies the above equation.

Parameters:
other The StridedPointer instance to subtract from *this.
Returns:
A difference value as described above.

Definition at line 193 of file stridedPointer.h.

References dlr::common::StridedPointer< Type >::m_pointer.

template<class Type>
StridedPointer<Type> dlr::common::StridedPointer< Type >::operator- ( ptrdiff_t  offset  )  [inline]

This operator works just like operator+() above, but decreases the StridedPointer value instead of increasing it.

Parameters:
offset This argument specifies how many steps to move back.
Returns:
A copy of *this which references the new location.

Definition at line 175 of file stridedPointer.h.

template<class Type>
StridedPointer<Type> dlr::common::StridedPointer< Type >::operator-- ( int   )  [inline]

The post-decrement operator is just like the post-increment operator, above, but increments instead of decrements.

Returns:
An un-decremented copy of *this.

Definition at line 144 of file stridedPointer.h.

template<class Type>
StridedPointer<Type>& dlr::common::StridedPointer< Type >::operator-- (  )  [inline]

The pre-decrement operator is just like the pre-increment operator, above, but increments instead of decrements.

Returns:
A Reference to the decremented StridedPointer instance.

Definition at line 136 of file stridedPointer.h.

template<class Type>
StridedPointer<Type>& dlr::common::StridedPointer< Type >::operator-= ( ptrdiff_t  offset  )  [inline]

This operator has the same effect as decrementing *this offset times, but runs in O(1) time.

Parameters:
offset This argument specifies how many steps to decrement the StridedPointer.
Returns:
A reference to *this.

Definition at line 219 of file stridedPointer.h.

template<class Type>
Type* dlr::common::StridedPointer< Type >::operator-> (  )  [inline]

The access operator allows you to access the member functions and member variables of the value to which this StridedPointer instance currently points, just as you would with a normal pointer.

Use it like this:

StridedPointer<myClass> ptr(...); ptr->someMethod();

Returns:
C-style pointer to the value pointed to by this StridedPointer instance.

Definition at line 105 of file stridedPointer.h.

template<class Type>
bool dlr::common::StridedPointer< Type >::operator< ( const StridedPointer< Type > &  other  )  const [inline]

This operator return true if the address of the memory location referenced by *this is less than the address of the memory location referenced by other, false otherwise.

Parameters:
other The StridedPointer instance to be compared with *this.
Returns:
true if the address of the memory location referenced by *this is less than the address of the memory location referenced by other, false otherwise.

Definition at line 259 of file stridedPointer.h.

template<class Type>
bool dlr::common::StridedPointer< Type >::operator<= ( const StridedPointer< Type > &  other  )  const [inline]

This operator return true if the address of the memory location referenced by *this is less than or equal to the address of the memory location referenced by other, false otherwise.

Parameters:
other The StridedPointer instance to be compared with *this.
Returns:
true if the address of the memory location referenced by *this is less than or equal to the address of the memory location referenced by other, false otherwise.

Definition at line 289 of file stridedPointer.h.

template<class Type>
StridedPointer<Type>& dlr::common::StridedPointer< Type >::operator= ( const StridedPointer< Type > &  source  )  [inline]

The assignment operator copies both address and stride from its argument.

Parameters:
source The StridedPointer instance to be copied.
Returns:
A reference to *this.

Definition at line 315 of file stridedPointer.h.

References dlr::common::StridedPointer< Type >::m_pointer, and dlr::common::StridedPointer< Type >::m_stride.

template<class Type>
bool dlr::common::StridedPointer< Type >::operator== ( const StridedPointer< Type > &  other  )  const [inline]

This operator returns true if its argument references the same memory location as *this, false otherwise.

Parameters:
other A StridedPointer instance to be compared with *this.
Returns:
true if other references same memory location as *this, false otherwise.

Definition at line 232 of file stridedPointer.h.

References dlr::common::StridedPointer< Type >::m_pointer.

template<class Type>
bool dlr::common::StridedPointer< Type >::operator> ( const StridedPointer< Type > &  other  )  const [inline]

This operator return true if the address of the memory location referenced by *this is greater than the address of the memory location referenced by other, false otherwise.

Parameters:
other The StridedPointer instance to be compared with *this.
Returns:
true if the address of the memory location referenced by *this is greater than the address of the memory location referenced by other, false otherwise.

Definition at line 274 of file stridedPointer.h.

References dlr::common::StridedPointer< Type >::m_pointer.

template<class Type>
bool dlr::common::StridedPointer< Type >::operator>= ( const StridedPointer< Type > &  other  )  const [inline]

This operator return true if the address of the memory location referenced by *this is greater than or equal to the address of the memory location referenced by other, false otherwise.

Parameters:
other The StridedPointer instance to be compared with *this.
Returns:
true if the address of the memory location referenced by *this is greater than or equal to the address of the memory location referenced by other, false otherwise.

Definition at line 304 of file stridedPointer.h.

References dlr::common::StridedPointer< Type >::m_pointer.


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

Generated on Tue Nov 24 23:57:57 2009 for dlrCommon Utility Library by  doxygen 1.5.8