The Original CHomP Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
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>

Public Member Functions

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

Private Member Functions

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

Private Attributes

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

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 950 of file chains.h.

Constructor & Destructor Documentation

◆ simplelist() [1/2]

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

The default constructor of an empty list.

Definition at line 1003 of file chains.h.

1003 : num (0), cur (0), elem (NULL)
1004{
1005 return;
1006} /* simplelist::simplelist */
int cur
The current element in the table.
Definition: chains.h:993
element ** elem
A table of element pointers.
Definition: chains.h:996
int num
The number of element pointers stored in the list.
Definition: chains.h:990

◆ ~simplelist()

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

The destructor.

Definition at line 1009 of file chains.h.

1010{
1011 if (elem)
1012 delete [] elem;
1013 return;
1014} /* simplelist::~simplelist */

◆ simplelist() [2/2]

template<class element >
chomp::homology::simplelist< element >::simplelist ( const simplelist< element > &  s)
inlineprivate

The copy constructor is not implemented.

Definition at line 974 of file chains.h.

975 {
976 throw "Copying constructor not implemented "
977 "for a simple list.";
978 return;
979 }

Member Function Documentation

◆ add()

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

Adds an element to the list.

Definition at line 1017 of file chains.h.

1018{
1019 element **newelem = new element * [num + 1];
1020 for (int i = 0; i < num; ++ i)
1021 newelem [i] = elem [i];
1022 newelem [num ++] = &m;
1023 delete [] elem;
1024 elem = newelem;
1025 return;
1026} /* simplelist::add */

◆ operator=()

template<class element >
simplelist< element > & chomp::homology::simplelist< element >::operator= ( const simplelist< element > &  s)
inlineprivate

The assignment operator is not implemented.

Definition at line 982 of file chains.h.

983 {
984 throw "Operator = not implemented "
985 "for a simple list.";
986 return *this;
987 }

◆ remove()

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

Remove an element from the list.

Definition at line 1029 of file chains.h.

1030{
1031 int pos = 0;
1032 while ((pos < num) && (elem [pos] != &m))
1033 ++ pos;
1034 -- num;
1035 while (pos < num)
1036 {
1037 elem [pos] = elem [pos + 1];
1038 ++ pos;
1039 }
1040 return;
1041} /* simplelist::remove */

◆ take()

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 1044 of file chains.h.

1045{
1046 if (cur >= num)
1047 {
1048 cur = 0;
1049 return NULL;
1050 }
1051 else
1052 {
1053 return elem [cur ++];
1054 }
1055} /* simplelist::take */

Member Data Documentation

◆ cur

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

The current element in the table.

Definition at line 993 of file chains.h.

◆ elem

template<class element >
element** chomp::homology::simplelist< element >::elem
private

A table of element pointers.

Definition at line 996 of file chains.h.

◆ num

template<class element >
int chomp::homology::simplelist< element >::num
private

The number of element pointers stored in the list.

Definition at line 990 of file chains.h.


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