The Original CHomP Software
Public Member Functions | Public Attributes | Private Attributes | List of all members
chomp::homology::mvmap< domelement, imgelement > Class Template Reference

This class defines a multivalued map. More...

#include <hashsets.h>

Public Member Functions

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

Public Attributes

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

Private Attributes

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

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 944 of file hashsets.h.

Constructor & Destructor Documentation

◆ mvmap()

template<class domelement , class imgelement >
chomp::homology::mvmap< domelement, imgelement >::mvmap ( int  bequiet = 1)
inlineexplicit

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 1013 of file hashsets.h.

1013 :
1014 domain (0, bequiet), images ()
1015{
1016 return;
1017} /* mvmap::mvmap */
hashedset< domelement > domain
The domain of the map.
Definition: hashsets.h:1002
multitable< hashedset< imgelement > > images
The images of cubes from the domain.
Definition: hashsets.h:1006

◆ ~mvmap()

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

The destructor.

Definition at line 1020 of file hashsets.h.

1021{
1022 return;
1023} /* mvmap::~mvmap */

Member Function Documentation

◆ get()

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 1026 of file hashsets.h.

1027{
1028 if ((n < 0) || (n >= domain. size ()))
1029 throw "Domain element number out of range.";
1030 return domain [n];
1031} /* mvmap::get */
int_t size() const
Returns the number of elements in the domain of the map.
Definition: hashsets.h:1079

◆ getdomain()

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

Retrieves the domain of the map for reading only.

Definition at line 1035 of file hashsets.h.

1036{
1037 return domain;
1038} /* mvmap::getdomain */

◆ operator()() [1/2]

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 1051 of file hashsets.h.

1053{
1054 int_t n = domain. getnumber (q);
1055 if (n < 0)
1056 throw "Element not in the domain.";
1057 return images (n);
1058} /* mvmap::operator () */
int int_t
Index type for indexing arrays, counting cubes, etc.
Definition: config.h:115

◆ operator()() [2/2]

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 1042 of file hashsets.h.

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

◆ operator[]() [1/2]

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 1071 of file hashsets.h.

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

◆ operator[]() [2/2]

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 1062 of file hashsets.h.

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

◆ remove() [1/2]

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 1100 of file hashsets.h.

1101{
1102 return removenum (domain. getnumber (x));
1103} /* mvmap::remove */
bool removenum(int_t n)
Removes the n-th element from the domain of the map.
Definition: hashsets.h:1085

◆ remove() [2/2]

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 1106 of file hashsets.h.

1108{
1109 int_t n = x. size ();
1110 for (int_t i = 0; i < n; ++ i)
1111 remove (x [i]);
1112 return;
1113} /* mvmap::remove */
bool remove(const domelement &x)
Removes an element from the domain of the map.
Definition: hashsets.h:1100

◆ removenum()

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 1085 of file hashsets.h.

1088{
1089 if ((n < 0) || (n >= domain. size ()))
1090 return false;
1091 domain. removenum (n);
1092 if (n != domain. size ())
1093 images [n] = images [domain. size ()];
1094 hashedset<imgelement> empty;
1095 images [domain. size ()] = empty;
1096 return true;
1097} /* mvmap::removenum */

◆ size()

template<class domelement , class imgelement >
int_t chomp::homology::mvmap< domelement, imgelement >::size
inline

Returns the number of elements in the domain of the map.

Definition at line 1079 of file hashsets.h.

1080{
1081 return domain. size ();
1082} /* mvmap::size */

◆ swap()

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 1116 of file hashsets.h.

1118{
1119 domain. swap (other. domain);
1120 images. swap (other. images);
1121 return;
1122} /* mvmap::swap */
void swap(mvmap< domelement, imgelement > &other)
Swaps the internal data of two multivalued maps.
Definition: hashsets.h:1117

References chomp::multiwork::swap().

Member Data Documentation

◆ domain

template<class domelement , class imgelement >
hashedset<domelement> chomp::homology::mvmap< domelement, imgelement >::domain
private

The domain of the map.

Definition at line 1002 of file hashsets.h.

◆ images

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 1006 of file hashsets.h.

◆ quiet

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 998 of file hashsets.h.


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