Public Member Functions | Private Member Functions | Private Attributes

chomp::homology::simplelist< element > Class Template Reference

This class defines a simple list of pointers to objects of the given type. More...

#include <chains.h>

List of all members.

Public Member Functions

 simplelist ()
 The default constructor of an empty list.
 ~simplelist ()
 The destructor.
void add (element &m)
 Adds an element to the list.
void remove (element &m)
 Remove an element from the list.
element * take ()
 A simple internal iterator of the list.

Private Member Functions

 simplelist (const simplelist< element > &s)
 The copy constructor is not implemented.
simplelist< element > & operator= (const simplelist< element > &s)
 The assignment operator is not implemented.

Private Attributes

int num
 The number of element pointers stored in the list.
int cur
 The current element in the table.
element ** elem
 A table of element pointers.

Detailed Description

template<class element>
class chomp::homology::simplelist< element >

This class defines a simple list of pointers to objects of the given type.

It is a helper class used in chain complex.

Definition at line 1177 of file chains.h.


Constructor & Destructor Documentation

template<class element >
chomp::homology::simplelist< element >::simplelist (  )  [inline]

The default constructor of an empty list.

Definition at line 1230 of file chains.h.

                                       : num (0), cur (0), elem (NULL)
{
        return;
} /* simplelist::simplelist */

template<class element >
chomp::homology::simplelist< element >::~simplelist (  )  [inline]

The destructor.

Definition at line 1236 of file chains.h.

References chomp::homology::simplelist< element >::elem.

{
        if (elem)
                delete [] elem;
        return;
} /* simplelist::~simplelist */

template<class element>
chomp::homology::simplelist< element >::simplelist ( const simplelist< element > &  s  )  [inline, private]

The copy constructor is not implemented.

Definition at line 1201 of file chains.h.

        {
                throw "Copying constructor not implemented "
                        "for a simple list.";
                return;
        }


Member Function Documentation

template<class element>
void chomp::homology::simplelist< element >::add ( element &  m  )  [inline]

Adds an element to the list.

Definition at line 1244 of file chains.h.

References chomp::homology::simplelist< element >::elem, and chomp::homology::simplelist< element >::num.

{
        element **newelem = new element * [num + 1];
        for (int i = 0; i < num; ++ i)
                newelem [i] = elem [i];
        newelem [num ++] = &m;
        delete [] elem;
        elem = newelem;
        return;
} /* simplelist::add */

template<class element>
simplelist<element>& chomp::homology::simplelist< element >::operator= ( const simplelist< element > &  s  )  [inline, private]

The assignment operator is not implemented.

Definition at line 1209 of file chains.h.

        {
                throw "Operator = not implemented "
                        "for a simple list.";
                return *this;
        }

template<class element>
void chomp::homology::simplelist< element >::remove ( element &  m  )  [inline]

Remove an element from the list.

Definition at line 1256 of file chains.h.

References chomp::homology::simplelist< element >::elem, and chomp::homology::simplelist< element >::num.

{
        int pos = 0;
        while ((pos < num) && (elem [pos] != &m))
                ++ pos;
        -- num;
        while (pos < num)
        {
                elem [pos] = elem [pos + 1];
                ++ pos;
        }
        return;
} /* simplelist::remove */

template<class element >
element * chomp::homology::simplelist< element >::take (  )  [inline]

A simple internal iterator of the list.

A call to this function returns an element from the list, but does not remove it from the list, and sets the internal iterator for the next element. After the last element has been taken, returns 0 and rewinds the iterator to the beginning of the list.

Definition at line 1271 of file chains.h.

References chomp::homology::simplelist< element >::cur, chomp::homology::simplelist< element >::elem, and chomp::homology::simplelist< element >::num.

{
        if (cur >= num)
        {
                cur = 0;
                return NULL;
        }
        else
        {
                return elem [cur ++];
        }
} /* simplelist::take */


Member Data Documentation

template<class element>
int chomp::homology::simplelist< element >::cur [private]

The current element in the table.

Definition at line 1220 of file chains.h.

Referenced by chomp::homology::simplelist< element >::take().

template<class element>
element** chomp::homology::simplelist< element >::elem [private]
template<class element>
int chomp::homology::simplelist< element >::num [private]

The number of element pointers stored in the list.

Definition at line 1217 of file chains.h.

Referenced by chomp::homology::simplelist< element >::add(), chomp::homology::simplelist< element >::remove(), and chomp::homology::simplelist< element >::take().


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