Circulator< ContainerType > Class Template Reference

Walks over a container as if it were circular. The container must have the following members defined: More...

Inheritance diagram for Circulator< ContainerType >:
[legend]
Collaboration diagram for Circulator< ContainerType >:
[legend]

Public Types

typedef ContainerType::value_type value_type
 Type of values ContainerType contains. More...
 
typedef ContainerType::size_type size_type
 The type that can represent the size of ContainerType. More...
 
typedef ContainerType::difference_type difference_type
 The type that can represent the difference between any two. More...
 
typedef ContainerType::iterator iterator
 Random access iterator for traversing ContainerType. More...
 
typedef ContainerType::reference reference
 Type that can be used for storing into. More...
 
- Public Types inherited from CirculatorBase
enum  direction { NONE, CLOCKWISE, ANTICLOCKWISE }
 Direction type enumeration. More...
 

Public Member Functions

 Circulator ()
 Construct null. More...
 
 Circulator (ContainerType &container)
 Construct from a container. More...
 
 Circulator (const iterator &begin, const iterator &end)
 Construct from two iterators. More...
 
 Circulator (const Circulator< ContainerType > &)
 Construct as copy. More...
 
 ~Circulator ()
 Destructor. More...
 
size_type size () const
 Return the range of the iterator. More...
 
bool circulate (const CirculatorBase::direction dir=NONE)
 Circulate around the list in the given direction. More...
 
void setFulcrumToIterator ()
 Set the fulcrum to the current position of the iterator. More...
 
void setIteratorToFulcrum ()
 Set the iterator to the current position of the fulcrum. More...
 
difference_type nRotations () const
 Return the distance between the iterator and the fulcrum. This is. More...
 
reference next () const
 Dereference the next iterator and return. More...
 
reference prev () const
 Dereference the previous iterator and return. More...
 
void operator= (const Circulator< ContainerType > &)
 Assignment operator for Circulators that operate on the same. More...
 
Circulator< ContainerType > & operator++ ()
 Prefix increment. Increments the iterator. More...
 
Circulator< ContainerType > operator++ (int)
 Postfix increment. Increments the iterator. More...
 
Circulator< ContainerType > & operator-- ()
 Prefix decrement. Decrements the iterator. More...
 
Circulator< ContainerType > operator-- (int)
 Postfix decrement. Decrements the iterator. More...
 
bool operator== (const Circulator< ContainerType > &c) const
 Check for equality of this iterator with another iterator that. More...
 
bool operator!= (const Circulator< ContainerType > &c) const
 Check for inequality of this iterator with another iterator that. More...
 
reference operator* () const
 Dereference the iterator and return. More...
 
reference operator() () const
 Dereference the iterator and return. More...
 
difference_type operator- (const Circulator< ContainerType > &c) const
 Return the difference between this iterator and another iterator. More...
 
- Public Member Functions inherited from CirculatorBase
 CirculatorBase ()
 Construct null. More...
 

Protected Attributes

ContainerType::iterator begin_
 Iterator pointing to the beginning of the container. More...
 
ContainerType::iterator end_
 Iterator pointing to the end of the container. More...
 
ContainerType::iterator iter_
 Random access iterator for traversing ContainerType. More...
 
ContainerType::iterator fulcrum_
 Iterator holding the location of the fulcrum (start and end) of. More...
 

Detailed Description

template<class ContainerType>
class Foam::Circulator< ContainerType >

Walks over a container as if it were circular. The container must have the following members defined:

- value_type

  • size_type
  • difference_type
  • iterator
  • reference

Examples

face f(identity(5));
// Construct Circulator from the face
Circulator<face> circ(f);
// First check that the Circulator has a size to iterate over.
// Then circulate around the list starting and finishing at the fulcrum.
if (circ.size()) do
{
circ() += 1;
Info<< "Iterate forwards over face : " << circ() << endl;
} while (circ.circulate(CirculatorBase::CLOCKWISE));
Source files

Definition at line 77 of file Circulator.H.

Member Typedef Documentation

◆ value_type

typedef ContainerType::value_type value_type

Type of values ContainerType contains.

Definition at line 106 of file Circulator.H.

◆ size_type

typedef ContainerType::size_type size_type

The type that can represent the size of ContainerType.

Definition at line 109 of file Circulator.H.

◆ difference_type

typedef ContainerType::difference_type difference_type

The type that can represent the difference between any two.

iterator objects.

Definition at line 113 of file Circulator.H.

◆ iterator

typedef ContainerType::iterator iterator

Random access iterator for traversing ContainerType.

Definition at line 116 of file Circulator.H.

◆ reference

typedef ContainerType::reference reference

Type that can be used for storing into.

ContainerType::value_type objects.

Definition at line 120 of file Circulator.H.

Constructor & Destructor Documentation

◆ Circulator() [1/4]

Circulator ( )
inline

Construct null.

Definition at line 32 of file CirculatorI.H.

◆ Circulator() [2/4]

Circulator ( ContainerType &  container)
inlineexplicit

Construct from a container.

Definition at line 43 of file CirculatorI.H.

◆ Circulator() [3/4]

Circulator ( const iterator begin,
const iterator end 
)
inline

Construct from two iterators.

Definition at line 55 of file CirculatorI.H.

◆ Circulator() [4/4]

Circulator ( const Circulator< ContainerType > &  rhs)
inline

Construct as copy.

Definition at line 70 of file CirculatorI.H.

◆ ~Circulator()

~Circulator ( )

Destructor.

Definition at line 85 of file CirculatorI.H.

Member Function Documentation

◆ size()

Foam::Circulator< ContainerType >::size_type size ( ) const
inline

Return the range of the iterator.

Definition at line 93 of file CirculatorI.H.

◆ circulate()

bool circulate ( const CirculatorBase::direction  dir = NONE)
inline

Circulate around the list in the given direction.

Definition at line 101 of file CirculatorI.H.

References CirculatorBase::ANTICLOCKWISE, and CirculatorBase::CLOCKWISE.

◆ setFulcrumToIterator()

void setFulcrumToIterator ( )
inline

Set the fulcrum to the current position of the iterator.

Definition at line 119 of file CirculatorI.H.

◆ setIteratorToFulcrum()

void setIteratorToFulcrum ( )
inline

Set the iterator to the current position of the fulcrum.

Definition at line 126 of file CirculatorI.H.

◆ nRotations()

Foam::Circulator< ContainerType >::difference_type nRotations ( ) const
inline

Return the distance between the iterator and the fulcrum. This is.

equivalent to the number of rotations of the Circulator.

Definition at line 134 of file CirculatorI.H.

◆ next()

Foam::Circulator< ContainerType >::reference next ( ) const
inline

Dereference the next iterator and return.

Definition at line 142 of file CirculatorI.H.

◆ prev()

Foam::Circulator< ContainerType >::reference prev ( ) const
inline

Dereference the previous iterator and return.

Definition at line 155 of file CirculatorI.H.

◆ operator=()

void operator= ( const Circulator< ContainerType > &  rhs)
inline

Assignment operator for Circulators that operate on the same.

container type

Definition at line 170 of file CirculatorI.H.

References Circulator< ContainerType >::begin_, Circulator< ContainerType >::end_, Circulator< ContainerType >::fulcrum_, and Circulator< ContainerType >::iter_.

◆ operator++() [1/2]

Foam::Circulator< ContainerType > & operator++ ( )
inline

Prefix increment. Increments the iterator.

Sets the iterator to the beginning of the container if it reaches the end

Definition at line 188 of file CirculatorI.H.

◆ operator++() [2/2]

Foam::Circulator< ContainerType > operator++ ( int  )
inline

Postfix increment. Increments the iterator.

Sets the iterator to the beginning of the container if it reaches the end

Definition at line 202 of file CirculatorI.H.

◆ operator--() [1/2]

Foam::Circulator< ContainerType > & operator-- ( )
inline

Prefix decrement. Decrements the iterator.

Sets the iterator to the end of the container if it reaches the beginning

Definition at line 212 of file CirculatorI.H.

◆ operator--() [2/2]

Foam::Circulator< ContainerType > operator-- ( int  )
inline

Postfix decrement. Decrements the iterator.

Sets the iterator to the end of the container if it reaches the beginning

Definition at line 226 of file CirculatorI.H.

◆ operator==()

bool operator== ( const Circulator< ContainerType > &  c) const
inline

Check for equality of this iterator with another iterator that.

operate on the same container type

Definition at line 236 of file CirculatorI.H.

References Foam::constant::universal::c.

◆ operator!=()

bool operator!= ( const Circulator< ContainerType > &  c) const
inline

Check for inequality of this iterator with another iterator that.

operate on the same container type

Definition at line 252 of file CirculatorI.H.

References Foam::constant::universal::c.

◆ operator*()

Foam::Circulator< ContainerType >::reference operator* ( ) const
inline

Dereference the iterator and return.

Definition at line 262 of file CirculatorI.H.

◆ operator()()

Foam::Circulator< ContainerType >::reference operator() ( ) const
inline

Dereference the iterator and return.

Definition at line 270 of file CirculatorI.H.

References Foam::operator*().

Here is the call graph for this function:

◆ operator-()

Foam::Circulator< ContainerType >::difference_type operator- ( const Circulator< ContainerType > &  c) const
inline

Return the difference between this iterator and another iterator.

that operate on the same container type

Definition at line 279 of file CirculatorI.H.

References Foam::constant::universal::c.

Member Data Documentation

◆ begin_

ContainerType::iterator begin_
protected

Iterator pointing to the beginning of the container.

Definition at line 87 of file Circulator.H.

Referenced by Circulator< ContainerType >::operator=().

◆ end_

ContainerType::iterator end_
protected

Iterator pointing to the end of the container.

Definition at line 90 of file Circulator.H.

Referenced by Circulator< ContainerType >::operator=().

◆ iter_

ContainerType::iterator iter_
protected

Random access iterator for traversing ContainerType.

Definition at line 93 of file Circulator.H.

Referenced by Circulator< ContainerType >::operator=().

◆ fulcrum_

ContainerType::iterator fulcrum_
protected

Iterator holding the location of the fulcrum (start and end) of.

the container. Used to decide when the iterator should stop circulating over the container

Definition at line 98 of file Circulator.H.

Referenced by Circulator< ContainerType >::operator=().


The documentation for this class was generated from the following files:
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::CirculatorBase::CLOCKWISE
Definition: CirculatorBase.H:56
f
labelList f(nPoints)
Foam::identity
labelList identity(const label len, label start=0)
Create identity map of the given length with (map[i] == i)
Definition: labelList.C:38