PPL  1.2
Parma_Polyhedra_Library::Implementation::EList< T > Class Template Reference

A simple kind of embedded list (i.e., a doubly linked objects where the links are embedded in the objects themselves). More...

#include <EList_defs.hh>

Inheritance diagram for Parma_Polyhedra_Library::Implementation::EList< T >:
Collaboration diagram for Parma_Polyhedra_Library::Implementation::EList< T >:

Public Types

typedef EList_Iterator< const T > const_iterator
 A const iterator to traverse the list. More...
 
typedef EList_Iterator< T > iterator
 A non-const iterator to traverse the list. More...
 

Public Member Functions

 EList ()
 Constructs an empty list. More...
 
 ~EList ()
 Destructs the list and all the elements in it. More...
 
void push_front (T &obj)
 Pushes obj to the front of the list. More...
 
void push_back (T &obj)
 Pushes obj to the back of the list. More...
 
iterator insert (iterator position, T &obj)
 Inserts obj just before position and returns an iterator that points to the inserted object. More...
 
iterator erase (iterator position)
 Removes the element pointed to by position, returning an iterator pointing to the next element, if any, or end(), otherwise. More...
 
bool empty () const
 Returns true if and only if the list is empty. More...
 
iterator begin ()
 Returns an iterator pointing to the beginning of the list. More...
 
iterator end ()
 Returns an iterator pointing one past the last element in the list. More...
 
const_iterator begin () const
 Returns a const iterator pointing to the beginning of the list. More...
 
const_iterator end () const
 Returns a const iterator pointing one past the last element in the list. More...
 
bool OK () const
 Checks if all the invariants are satisfied. More...
 

Additional Inherited Members

- Private Member Functions inherited from Parma_Polyhedra_Library::Implementation::Doubly_Linked_Object
 Doubly_Linked_Object ()
 Default constructor. More...
 
 Doubly_Linked_Object (Doubly_Linked_Object *f, Doubly_Linked_Object *b)
 Creates a chain element with forward link f and backward link b. More...
 
void insert_before (Doubly_Linked_Object &y)
 Inserts y before *this. More...
 
void insert_after (Doubly_Linked_Object &y)
 Inserts y after *this. More...
 
Doubly_Linked_Objecterase ()
 Erases *this from the chain and returns a pointer to the next element. More...
 
 ~Doubly_Linked_Object ()
 Erases *this from the chain. More...
 

Detailed Description

template<typename T>
class Parma_Polyhedra_Library::Implementation::EList< T >

A simple kind of embedded list (i.e., a doubly linked objects where the links are embedded in the objects themselves).

Definition at line 36 of file EList_defs.hh.

Member Typedef Documentation

A const iterator to traverse the list.

Definition at line 40 of file EList_defs.hh.

A non-const iterator to traverse the list.

Definition at line 43 of file EList_defs.hh.

Constructor & Destructor Documentation

template<typename T >
Parma_Polyhedra_Library::Implementation::EList< T >::EList ( )
inline

Constructs an empty list.

Definition at line 35 of file EList_inlines.hh.

template<typename T >
Parma_Polyhedra_Library::Implementation::EList< T >::~EList ( )
inline

Destructs the list and all the elements in it.

Definition at line 97 of file EList_inlines.hh.

97  {
98  // Erase and deallocate all the elements.
99  for (iterator i = begin(), lend = end(), next; i != lend; i = next) {
100  next = erase(i);
101  delete &*i;
102  }
103 }
iterator begin()
Returns an iterator pointing to the beginning of the list.
Doubly_Linked_Object * erase()
Erases *this from the chain and returns a pointer to the next element.
iterator end()
Returns an iterator pointing one past the last element in the list.
EList_Iterator< T > iterator
A non-const iterator to traverse the list.
Definition: EList_defs.hh:43

Member Function Documentation

template<typename T >
EList< T >::iterator Parma_Polyhedra_Library::Implementation::EList< T >::begin ( )
inline

Returns an iterator pointing to the beginning of the list.

Definition at line 60 of file EList_inlines.hh.

60  {
61  return iterator(next);
62 }
EList_Iterator< T > iterator
A non-const iterator to traverse the list.
Definition: EList_defs.hh:43
template<typename T >
EList< T >::const_iterator Parma_Polyhedra_Library::Implementation::EList< T >::begin ( ) const
inline

Returns a const iterator pointing to the beginning of the list.

Definition at line 72 of file EList_inlines.hh.

72  {
73  return const_iterator(next);
74 }
EList_Iterator< const T > const_iterator
A const iterator to traverse the list.
Definition: EList_defs.hh:40
template<typename T >
bool Parma_Polyhedra_Library::Implementation::EList< T >::empty ( ) const
inline

Returns true if and only if the list is empty.

Definition at line 84 of file EList_inlines.hh.

84  {
85  return begin() == end();
86 }
iterator begin()
Returns an iterator pointing to the beginning of the list.
iterator end()
Returns an iterator pointing one past the last element in the list.
template<typename T >
EList< T >::iterator Parma_Polyhedra_Library::Implementation::EList< T >::end ( )
inline

Returns an iterator pointing one past the last element in the list.

Definition at line 66 of file EList_inlines.hh.

66  {
67  return iterator(this);
68 }
EList_Iterator< T > iterator
A non-const iterator to traverse the list.
Definition: EList_defs.hh:43
template<typename T >
EList< T >::const_iterator Parma_Polyhedra_Library::Implementation::EList< T >::end ( ) const
inline

Returns a const iterator pointing one past the last element in the list.

Definition at line 78 of file EList_inlines.hh.

78  {
79  return const_iterator(const_cast<EList<T>*>(this));
80 }
EList_Iterator< const T > const_iterator
A const iterator to traverse the list.
Definition: EList_defs.hh:40
template<typename T >
EList< T >::iterator Parma_Polyhedra_Library::Implementation::EList< T >::erase ( iterator  position)
inline

Removes the element pointed to by position, returning an iterator pointing to the next element, if any, or end(), otherwise.

Definition at line 90 of file EList_inlines.hh.

References Parma_Polyhedra_Library::Implementation::BD_Shapes::empty.

90  {
91  assert(!empty());
92  return iterator(position->erase());
93 }
EList_Iterator< T > iterator
A non-const iterator to traverse the list.
Definition: EList_defs.hh:43
bool empty() const
Returns true if and only if the list is empty.
template<typename T>
EList< T >::iterator Parma_Polyhedra_Library::Implementation::EList< T >::insert ( iterator  position,
T &  obj 
)
inline

Inserts obj just before position and returns an iterator that points to the inserted object.

Definition at line 53 of file EList_inlines.hh.

53  {
54  position->insert_before(obj);
55  return iterator(&obj);
56 }
EList_Iterator< T > iterator
A non-const iterator to traverse the list.
Definition: EList_defs.hh:43
template<typename T >
bool Parma_Polyhedra_Library::Implementation::EList< T >::OK ( ) const
inline

Checks if all the invariants are satisfied.

Definition at line 107 of file EList_inlines.hh.

107  {
108  for (const_iterator i = begin(), lend = end(); i != lend; ++i) {
109  if (!i->OK()) {
110  return false;
111  }
112  }
113 
114  return true;
115 }
iterator begin()
Returns an iterator pointing to the beginning of the list.
iterator end()
Returns an iterator pointing one past the last element in the list.
EList_Iterator< const T > const_iterator
A const iterator to traverse the list.
Definition: EList_defs.hh:40
template<typename T>
void Parma_Polyhedra_Library::Implementation::EList< T >::push_back ( T &  obj)
inline

Pushes obj to the back of the list.

Definition at line 47 of file EList_inlines.hh.

47  {
48  prev->insert_after(obj);
49 }
void insert_after(Doubly_Linked_Object &y)
Inserts y after *this.
template<typename T>
void Parma_Polyhedra_Library::Implementation::EList< T >::push_front ( T &  obj)
inline

Pushes obj to the front of the list.

Definition at line 41 of file EList_inlines.hh.

41  {
42  next->insert_before(obj);
43 }
void insert_before(Doubly_Linked_Object &y)
Inserts y before *this.

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