Main Page Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages
more::gen::ring Class Template Reference
A ring is a collection of object which are bidirectionally linked into a ring.
More...
#include <more/ring.h>
Inheritance diagram for more::gen::ring:
[legend]List of all members.Public Types
|
Public Methods
Detailed Description
template<typename T, typename Alloc = more::gen::allocator<T>>
class more::gen::ring< T, Alloc >
A ring is a collection of object which are bidirectionally linked into a ring.
That is, a ring is like a list, but with the last element connected to the first. One of the nodes is called the principal node. This is the only node directly accessible, and is analogous to both the begin()
and end()
of other containers.
A ring of numbers from 0 to 7.
Note that there is no half-open range of iterators which span the whole ring. There are ranges which excludes one element, and there are pairs of half-open ranges which together span the ring.
One way to look at it is too see [it
, it)
as an ambiguous range which is empty or spans the whole ring. Inspired by this idea you can iterate over all nodes by skipping the first ``it != it_past_the_end'' test, as in
if (!r.empty()) {
iterator it = r.principal();
do some_code(it); while (++it != r.principal());
}
Member Typedef Documentation
template<typename T, typename Alloc = more::gen::allocator<T>> |
typedef Alloc more::gen::ring::allocator_type
|
|
template<typename T, typename Alloc = more::gen::allocator<T>> |
typedef allocator_type::const_pointer more::gen::ring::const_pointer
|
|
template<typename T, typename Alloc = more::gen::allocator<T>> |
typedef allocator_type::const_reference more::gen::ring::const_reference
|
|
template<typename T, typename Alloc = more::gen::allocator<T>> |
typedef allocator_type::difference_type more::gen::ring::difference_type
|
|
template<typename T, typename Alloc = more::gen::allocator<T>> |
typedef allocator_type::pointer more::gen::ring::pointer
|
|
template<typename T, typename Alloc = more::gen::allocator<T>> |
typedef allocator_type::reference more::gen::ring::reference
|
|
template<typename T, typename Alloc = more::gen::allocator<T>> |
typedef allocator_type::size_type more::gen::ring::size_type
|
|
template<typename T, typename Alloc = more::gen::allocator<T>> |
typedef T more::gen::ring::value_type
|
|
|
The standard container types.
|
Constructor & Destructor Documentation
template<typename T, typename Alloc = more::gen::allocator<T>> |
more::gen::ring< T, Alloc >::ring |
( |
|
) |
[inline] |
|
|
Construct an empty continer, which becomes a ring if you insert an element.
|
template<typename T, typename Alloc = more::gen::allocator<T>> |
more::gen::ring< T, Alloc >::ring |
( |
ring< T, Alloc > const & |
r |
) |
[inline] |
|
|
Construct a deep copy of x.
|
template<typename T, typename Alloc = more::gen::allocator<T>> |
more::gen::ring< T, Alloc >::~ring |
( |
|
) |
[inline] |
|
Member Function Documentation
template<typename T, typename Alloc = more::gen::allocator<T>> |
void more::gen::ring< T, Alloc >::clear |
( |
|
) |
[inline] |
|
|
Erase all nodes in the ring.
|
template<typename T, typename Alloc = more::gen::allocator<T>> |
bool more::gen::ring< T, Alloc >::empty |
( |
|
) |
const [inline] |
|
|
Returns true if the container contains no node.
|
template<typename T, typename Alloc = more::gen::allocator<T>> |
iterator more::gen::ring< T, Alloc >::erase |
( |
iterator |
it |
) |
[inline] |
|
|
Erase the node at it.
-
Returns:
-
an iterator to the next element if the container is non-empty after the operation, otherwise an invalid iterator.
|
template<typename T, typename Alloc = more::gen::allocator<T>> |
allocator_type more::gen::ring< T, Alloc >::get_allocator |
( |
|
) |
const [inline] |
|
template<typename T, typename Alloc = more::gen::allocator<T>> |
iterator more::gen::ring< T, Alloc >::insert |
( |
iterator |
it |
) |
[inline] |
|
|
Insert a default constructed object in front of it.
-
Precondition:
-
The allocator is extended to support default construction.
|
template<typename T, typename Alloc = more::gen::allocator<T>> |
iterator more::gen::ring< T, Alloc >::insert |
( |
iterator |
it, |
|
|
value_type const & |
val |
|
) |
[inline] |
|
|
Insert val in front of it.
|
template<typename T, typename Alloc = more::gen::allocator<T>> |
ring& more::gen::ring< T, Alloc >::operator= |
( |
ring< T, Alloc > const & |
x |
) |
[inline] |
|
template<typename T, typename Alloc = more::gen::allocator<T>> |
void more::gen::ring< T, Alloc >::pop_back |
( |
|
) |
[inline] |
|
|
Pop the principal node off the ring, and make the node before it the new principal.
|
template<typename T, typename Alloc = more::gen::allocator<T>> |
void more::gen::ring< T, Alloc >::pop_front |
( |
|
) |
[inline] |
|
|
Pop the principal node off the ring, and make the node after it the new principal.
|
template<typename T, typename Alloc = more::gen::allocator<T>> |
const_iterator more::gen::ring< T, Alloc >::principal |
( |
|
) |
const [inline] |
|
|
Returns an iterator to the principal node.
|
template<typename T, typename Alloc = more::gen::allocator<T>> |
iterator more::gen::ring< T, Alloc >::principal |
( |
|
) |
[inline] |
|
|
Returns an iterator to the principal node.
|
template<typename T, typename Alloc = more::gen::allocator<T>> |
void more::gen::ring< T, Alloc >::push_back |
( |
|
) |
[inline] |
|
|
Insert a default constructed object after the principal and make it the new principal.
-
Precondition:
-
The allocator is extended to support default construction.
|
template<typename T, typename Alloc = more::gen::allocator<T>> |
void more::gen::ring< T, Alloc >::push_back |
( |
value_type const & |
val |
) |
[inline] |
|
|
Insert val after the principal and make it the new principal.
If the ring is empty, set the principal to val. |
template<typename T, typename Alloc = more::gen::allocator<T>> |
void more::gen::ring< T, Alloc >::push_front |
( |
|
) |
[inline] |
|
|
Insert a default constructed object before the principal and make it the new principal.
-
Precondition:
-
The allocator is extended to support default construction.
|
template<typename T, typename Alloc = more::gen::allocator<T>> |
void more::gen::ring< T, Alloc >::push_front |
( |
value_type const & |
val |
) |
[inline] |
|
|
Insert val in before the principal and make it the new principal.
If the ring is empty, set the principal to val. |
template<typename T, typename Alloc = more::gen::allocator<T>> |
void more::gen::ring< T, Alloc >::rotate_clockwise |
( |
|
) |
[inline] |
|
|
Make the node before the principal node the next principal.
-
Precondition:
-
The ring is not empty.
|
template<typename T, typename Alloc = more::gen::allocator<T>> |
void more::gen::ring< T, Alloc >::rotate_counterclockwise |
( |
|
) |
[inline] |
|
|
Make the node after the principal node the next principal.
(Counterclockwise is usually taken as the positive direction of rotation.) -
Precondition:
-
The ring is not empty.
|
template<typename T, typename Alloc = more::gen::allocator<T>> |
size_type more::gen::ring< T, Alloc >::size |
( |
|
) |
const [inline] |
|
|
Number of members of the ring.
|
The documentation for this class was generated from the following file:
Generated on Sat Sep 7 19:12:36 2002 for more with Doxygen
1.2.13.1. Doxygen 1.2.13.1 is written and copyright
1997-2002 by Dimitri van
Heesch.