Public Member Functions | Public Attributes | Private Attributes

chomp::homology::mvmap< domelement, imgelement > Class Template Reference

This class defines a multivalued map. More...

#include <hashsets.h>

List of all members.

Public Member Functions

 mvmap (int bequiet=1)
 The default constructor.
 ~mvmap ()
 The destructor.
const domelement & get (int_t n) const
 Retrieves the n-th element from the domain for reading only.
const hashedset< domelement > & getdomain () const
 Retrieves the domain of the map for reading only.
const hashedset< imgelement > & operator() (int_t n) const
 Retrieve the image of the n-th element for reading only.
const hashedset< imgelement > & operator() (const domelement &x) const
 Retrieve the image of an element for reading only.
hashedset< imgelement > & operator[] (int_t n)
 Returns the image of the n-th element for writing.
hashedset< imgelement > & operator[] (const domelement &x)
 Returns the image of an element for writing.
int_t size () const
 Returns the number of elements in the domain of the map.
bool remove (const domelement &x)
 Removes an element from the domain of the map.
bool removenum (int_t n)
 Removes the n-th element from the domain of the map.
void remove (const hashedset< domelement > &x)
 Removes a set of elements from the domain of the map.
void swap (mvmap< domelement, imgelement > &other)
 Swaps the internal data of two multivalued maps.

Public Attributes

int quiet
 This variable indicates whether the map should be quiet.

Private Attributes

hashedset< domelement > domain
 The domain of the map.
multitable< hashedset
< imgelement > > 
images
 The images of cubes from the domain.

Detailed Description

template<class domelement, class imgelement>
class chomp::homology::mvmap< domelement, imgelement >

This class defines a multivalued map.

Each domain-type element is mapped into a hashed set of image-type elements. The images of elements can be accessed with the operator [] (for modifying) and operator () (for retrieval only). NOTE: Since the domain elements can be identified either by their value, or by their successive numbers, the domain cannot be a set of integers, because this would cause ambiguity.

Definition at line 938 of file hashsets.h.


Constructor & Destructor Documentation

template<class domelement , class imgelement >
chomp::homology::mvmap< domelement, imgelement >::mvmap ( int  bequiet = 1  )  [inline, explicit]

The default constructor.

The argument 'bequiet' is passed to the hashed set which represents the domain of the map. If set to zero, makes the domain display statistics information.

Definition at line 1007 of file hashsets.h.

                                                      :
        domain (0, bequiet), images ()
{
        return;
} /* mvmap::mvmap */

template<class domelement , class imgelement >
chomp::homology::mvmap< domelement, imgelement >::~mvmap (  )  [inline]

The destructor.

Definition at line 1014 of file hashsets.h.

{
        return;
} /* mvmap::~mvmap */


Member Function Documentation

template<class domelement , class imgelement >
const domelement & chomp::homology::mvmap< domelement, imgelement >::get ( int_t  n  )  const [inline]

Retrieves the n-th element from the domain for reading only.

Definition at line 1020 of file hashsets.h.

References chomp::homology::mvmap< domelement, imgelement >::domain, and chomp::homology::mvmap< domelement, imgelement >::size().

{
        if ((n < 0) || (n >= domain. size ()))
                throw "Domain element number out of range.";
        return domain [n];
} /* mvmap::get */

template<class domelement , class imgelement >
const hashedset< domelement > & chomp::homology::mvmap< domelement, imgelement >::getdomain (  )  const [inline]

Retrieves the domain of the map for reading only.

Definition at line 1029 of file hashsets.h.

References chomp::homology::mvmap< domelement, imgelement >::domain.

{
        return domain;
} /* mvmap::getdomain */

template<class domelement, class imgelement >
const hashedset< imgelement > & chomp::homology::mvmap< domelement, imgelement >::operator() ( const domelement &  x  )  const [inline]

Retrieve the image of an element for reading only.

Throws an exception if the element is not in the domain.

Definition at line 1046 of file hashsets.h.

{
        int_t n = domain. getnumber (q);
        if (n < 0)
                throw "Element not in the domain.";
        return images (n);
} /* mvmap::operator () */

template<class domelement , class imgelement >
const hashedset< imgelement > & chomp::homology::mvmap< domelement, imgelement >::operator() ( int_t  n  )  const [inline]

Retrieve the image of the n-th element for reading only.

Throws an exception if the number is out of range.

Definition at line 1036 of file hashsets.h.

References chomp::homology::mvmap< domelement, imgelement >::domain, chomp::homology::mvmap< domelement, imgelement >::images, and chomp::homology::mvmap< domelement, imgelement >::size().

{
        if ((n < 0) || (n >= domain. size ()))
                throw "Domain element number out of range.";
        return images (n);
} /* mvmap::operator () */

template<class domelement , class imgelement >
hashedset< imgelement > & chomp::homology::mvmap< domelement, imgelement >::operator[] ( int_t  n  )  [inline]

Returns the image of the n-th element for writing.

Definition at line 1056 of file hashsets.h.

References chomp::homology::mvmap< domelement, imgelement >::domain, chomp::homology::mvmap< domelement, imgelement >::images, and chomp::homology::mvmap< domelement, imgelement >::size().

{
        if ((n < 0) || (n >= domain. size ()))
                throw "Domain element number out of range.";
        return images [n];
} /* mvmap::operator [] */

template<class domelement, class imgelement >
hashedset< imgelement > & chomp::homology::mvmap< domelement, imgelement >::operator[] ( const domelement &  x  )  [inline]

Returns the image of an element for writing.

If the element is not in the domain, then it is added and a reference to its empty image is returned.

Definition at line 1066 of file hashsets.h.

{
        int_t n = domain. add (q);
        return images [n];
} /* mvmap::operator [] */

template<class domelement, class imgelement >
bool chomp::homology::mvmap< domelement, imgelement >::remove ( const domelement &  x  )  [inline]

Removes an element from the domain of the map.

Returns true if removed, false if it was not in the domain.

Definition at line 1094 of file hashsets.h.

References chomp::homology::mvmap< domelement, imgelement >::domain, and chomp::homology::mvmap< domelement, imgelement >::removenum().

{
        return removenum (domain. getnumber (x));
} /* mvmap::remove */

template<class domelement, class imgelement >
void chomp::homology::mvmap< domelement, imgelement >::remove ( const hashedset< domelement > &  x  )  [inline]

Removes a set of elements from the domain of the map.

Definition at line 1101 of file hashsets.h.

{
        int_t n = x. size ();
        for (int_t i = 0; i < n; ++ i)
                remove (x [i]);
        return;
} /* mvmap::remove */

template<class domelement , class imgelement >
bool chomp::homology::mvmap< domelement, imgelement >::removenum ( int_t  n  )  [inline]

Removes the n-th element from the domain of the map.

Definition at line 1079 of file hashsets.h.

References chomp::homology::mvmap< domelement, imgelement >::domain, chomp::homology::mvmap< domelement, imgelement >::images, and chomp::homology::mvmap< domelement, imgelement >::size().

Referenced by chomp::homology::mvmap< domelement, imgelement >::remove().

          : This procedure uses the specific way elements are removed from
// a hashed set. If that way is changed, this procedure may not work anymore.
{
        if ((n < 0) || (n >= domain. size ()))
                return false;
        domain. removenum (n);
        if (n != domain. size ())
                images [n] = images [domain. size ()];
        hashedset<imgelement> empty;
        images [domain. size ()] = empty;
        return true;
} /* mvmap::removenum */

template<class domelement , class imgelement >
int_t chomp::homology::mvmap< domelement, imgelement >::size (  )  const [inline]
template<class domelement, class imgelement>
void chomp::homology::mvmap< domelement, imgelement >::swap ( mvmap< domelement, imgelement > &  other  )  [inline]

Swaps the internal data of two multivalued maps.

Definition at line 1111 of file hashsets.h.

References chomp::multiwork::swap().

{
        domain. swap (other. domain);
        images. swap (other. images);
        return;
} /* mvmap::swap */


Member Data Documentation

template<class domelement, class imgelement>
hashedset<domelement> chomp::homology::mvmap< domelement, imgelement >::domain [private]
template<class domelement, class imgelement>
multitable<hashedset<imgelement> > chomp::homology::mvmap< domelement, imgelement >::images [private]

The images of cubes from the domain.

The order of these images is the same as the order of elements in the domain.

Definition at line 1000 of file hashsets.h.

Referenced by chomp::homology::mvmap< domelement, imgelement >::operator()(), chomp::homology::mvmap< domelement, imgelement >::operator[](), and chomp::homology::mvmap< domelement, imgelement >::removenum().

template<class domelement, class imgelement>
int chomp::homology::mvmap< domelement, imgelement >::quiet

This variable indicates whether the map should be quiet.

If set to false, the map may display some additional information about hashing statistics, etc.

Definition at line 992 of file hashsets.h.


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