rcolyer.net
RC Lib  Version 202403231100
Public Member Functions | List of all members
RC::RAIter< Cont, T > Class Template Reference

A bounds-checked iterator for random-access containers that knows when its target was deleted. More...

#include <Iter.h>

Inheritance diagram for RC::RAIter< Cont, T >:

Public Member Functions

 RAIter ()
 Default constructor to nothing, by default invalid for use.
 
 RAIter (RevPtr< Cont > container, size_t pos)
 Creates an iterator to a container starting at index pos. More...
 
bool IsValid () const
 True if the iterator still points to an existing container and remains in bounds.
 
size_t GetIndex () const
 Return the index of the container which this iterator corresponds to.
 
RevPtr< Cont > Raw ()
 Directly access the RevPtr to the container.
 
T & operator* ()
 Dereference the iterator, returning a reference to the corresponding element.
 
const T & operator* () const
 Const version of operator*.
 
const T * operator-> () const
 Provides access to members of the element this iterator points to.
 
T & operator[] (size_t x)
 Provides access to the element at offset x from the current index.
 
const T & operator[] (size_t x) const
 Const version of operator[].
 
RAIter< Cont, T > & operator++ ()
 Point to the next higher numbered indexed element.
 
RAIter< Cont, T > & operator-- ()
 Point to the next lower numbered indexed element.
 
RAIter< Cont, T > & operator+= (size_t x)
 Increase the index by x.
 
RAIter< Cont, T > & operator-= (size_t x)
 Decrease the index by x.
 
RAIter< Cont, T > operator++ (int)
 Support for iter++, but for efficiency, use ++iter.
 
RAIter< Cont, T > operator-- (int)
 Support for iter–, but for efficiency, use –iter.
 
RAIter< Cont, T > operator+ (size_t x) const
 Returns a new iterator with an offset incremented by x.
 
RAIter< Cont, T > operator- (size_t x) const
 Returns a new iterator with an offset decremented by x.
 
size_t operator- (const RAIter< Cont, T > &first) const
 Returns the distance between two iterators.
 
bool operator== (const RAIter< Cont, T > &other) const
 True if the two iterators have the same index.
 
bool operator< (const RAIter< Cont, T > &other) const
 True if this iterator is less.
 
template<class AnyValidType >
bool operator!= (const AnyValidType &other) const
 True if not equal.
 
template<class AnyValidType >
bool operator> (const AnyValidType &other) const
 True if other is less than this object.
 
template<class AnyValidType >
bool operator<= (const AnyValidType &other) const
 True if other is not less than this object.
 
template<class AnyValidType >
bool operator>= (const AnyValidType &other) const
 True if this object is not less than other.
 

Detailed Description

template<class Cont, class T>
class RC::RAIter< Cont, T >

A bounds-checked iterator for random-access containers that knows when its target was deleted.

See Data1D.h for a usage example.

Constructor & Destructor Documentation

◆ RAIter()

template<class Cont , class T >
RC::RAIter< Cont, T >::RAIter ( RevPtr< Cont >  container,
size_t  pos 
)
inline

Creates an iterator to a container starting at index pos.

When the iterator is dereferenced, it corresponds to (*container)[pos]. Note that the RevPtr for container should be set to AutoRevoke when the container is deleted.

Parameters
containerA RevPtr to the container.
posThe starting index for this iterator.

The documentation for this class was generated from the following file:
email address
— (c) 2015