35 #include <gsl/gsl_math.h>
104 return (gsl_fcmp(v1, v2, -1.0
E-6) < 0);
208 const T &
copy(
const T &src)
const {
243 return (allocate(*(src)));
254 template <
typename P>
255 P *allocate(
const P &obj)
const {
428 template <
typename K,
typename T,
429 template <
class>
class ComparePolicy = SimpleCompare,
431 template <
class>
class CopyPolicy = DefaultCopy
436 typedef std::multimap<K, CollectorType, ComparePolicy<K> >
CollectorList;
487 _keyPolicy = cmap._keyPolicy;
489 for(cItr = cmap._list.begin() ; cItr != cmap._list.end() ; cItr++) {
490 _list.insert(std::make_pair(cItr->first, cmap.copy(cItr->second)));
510 _keyPolicy = cmap._keyPolicy;
512 for(cItr = cmap._list.begin() ; cItr != cmap._list.end() ; cItr++) {
513 _list.insert(std::make_pair(cItr->first, cmap.copy(cItr->second)));
525 return (_list.size());
539 return (_list.count(key));
554 _list.insert(std::make_pair(key, value));
565 return (cItr != _list.end());
581 if(cItr == _list.end()) {
582 QString mess =
"Requested value does not exist!";
585 return (cItr->second);
593 const T &
get(
const K &
key)
const {
595 if(cItr == _list.end()) {
596 QString mess =
"Requested value does not exist!";
599 return (cItr->second);
616 if(cItr == _list.end()) {
620 return (std::distance(_list.begin(), cItr));
637 for(cItr = _list.begin(), i = 0 ; cItr != _list.end() ; ++cItr, i++) {
641 if(cItr == _list.end()) {
642 std::ostringstream mess;
643 mess <<
"Requested index (" << nth <<
") out of range" << std::endl;
646 return (cItr->second);
662 for(cItr = _list.begin(), i = 0 ; cItr != _list.end() ; ++cItr, i++) {
665 if(cItr == _list.end()) {
666 std::ostringstream mess;
667 mess <<
"Requested index (" << nth <<
") out of range" << std::endl;
670 return (cItr->second);
683 const K &
key(
int nth)
const {
686 for(cItr = _list.begin(), i = 0 ; cItr != _list.end() ; ++cItr, i++) {
689 if(cItr == _list.end()) {
690 std::ostringstream mess;
691 mess <<
"Requested key index (" << nth <<
") out of range" << std::endl;
694 return (cItr->first);
704 int remove(
const K &
key) {
706 if(Itr1 == _list.end())
return (0);
709 while(Itr1 != Itr2) {
710 this->destroy(&Itr1->second);
713 return (_list.erase(
key));
722 return _list.begin();
740 return _list.begin();
764 void selfDestruct() {
766 for(itr = _list.begin() ; itr != _list.end() ; itr++) {
767 this->destroy(&itr->second);
CollectorMap(const KeyPolicy &keyPolicy)
Allows the user to choose if keys can be duplicated.
Definition: CollectorMap.h:466
const K & key(int nth) const
Returns the nth key in the collection.
Definition: CollectorMap.h:683
bool exists(const K &key) const
Checks the existance of a particular key in the list.
Definition: CollectorMap.h:563
const double E(2.7182818284590452354)
Sets some basic constants for use in ISIS programming.
Policy for deleting arrays that CollectorMap owns.
Definition: CollectorMap.h:172
int index(const K &key) const
Returns the index of the first occuring element in the list.
Definition: CollectorMap.h:614
Provides a case insensitive string comparison.
Definition: CollectorMap.h:69
T & getNth(int nth)
Returns the nth value in the collection.
Definition: CollectorMap.h:634
CollectorConstIter begin() const
Const iterator into list.
Definition: CollectorMap.h:721
void destroy(T *element)
Destroys the CollectorMap pointer's CollectorMap.
Definition: CollectorMap.h:158
Provides a robust comparison of double/float values.
Definition: CollectorMap.h:93
Supplies a NOOP default for removal of a CollectorMap entry.
Definition: CollectorMap.h:118
CollectorList::iterator CollectorIter
CollectorList iterator type declaration.
Definition: CollectorMap.h:439
void destroy(T *element)
Destroys the CollectorMap entry.
Definition: CollectorMap.h:133
Allow duplication of keys.
Definition: CollectorMap.h:451
CollectorList::const_iterator CollectorConstIter
CollectorList constant iterator type declaration.
Definition: CollectorMap.h:441
CollectorMap()
Constructor.
Definition: CollectorMap.h:455
std::multimap< K, CollectorType, ComparePolicy< K > > CollectorList
Definition: CollectorMap.h:437
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:154
virtual ~CollectorMap()
Destructor handles removal of the elements within the collection.
Definition: CollectorMap.h:473
const T & getNth(int nth) const
Returns the nth value in the collection.
Definition: CollectorMap.h:659
(Default) Policy for copying map elements
Definition: CollectorMap.h:198
Supplies a policy for deleting pointers that CollectorMap owns.
Definition: CollectorMap.h:150
Constrain keys to be unique.
Definition: CollectorMap.h:450
void destroy(T *element)
Destroys the array of CollectorMaps.
Definition: CollectorMap.h:180
int count(const K &key) const
Returns the number of keys found in the list.
Definition: CollectorMap.h:538
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:38
void add(const K &key, const T &value)
Adds the element to the list.
Definition: CollectorMap.h:552
CollectorMap(const CollectorMap &cmap)
Copy constructor invokes the copy policy as provided by the users.
Definition: CollectorMap.h:486
CollectorIter end()
Returns the end of the list.
Definition: CollectorMap.h:749
bool operator()(const K &v1, const K &v2) const
Returns true if v1 is less than v2.
Definition: CollectorMap.h:56
KeyPolicy
Enumerated selection of key behaviour.
Definition: CollectorMap.h:450
Collector/container for arbitrary items.
Definition: CollectorMap.h:433
IString DownCase()
Converts all upper case letters in the object IString into lower case characters. ...
Definition: IString.cpp:659
CollectorConstIter end() const
Const iterator to end of list.
Definition: CollectorMap.h:730
const T & copy(const T &src) const
Returns a copy of the input.
Definition: CollectorMap.h:208
CollectorMap & operator=(const CollectorMap &cmap)
Assignment operator for the CollectorMap class object.
Definition: CollectorMap.h:507
T CollectorType
Data type A multimap attacking a key t...
Definition: CollectorMap.h:435
int size() const
Returns the size of the collection.
Definition: CollectorMap.h:524
Isis exception class.
Definition: IException.h:99
bool operator()(const K &v1, const K &v2) const
Compares v1 and v2 as floating point values.
Definition: CollectorMap.h:103
CollectorIter begin()
Returns the start of the list for iterating purposes.
Definition: CollectorMap.h:739
Provides a simple comparison between two values.
Definition: CollectorMap.h:46
bool operator()(const K &v1, const K &v2) const
Compares v1 and v2 as case insensitive strings, and returns true of v1 is less than v2 (as those stri...
Definition: CollectorMap.h:80
Pointer to object policy for copying map elements.
Definition: CollectorMap.h:230
T copy(const T &src) const
Allocate new object using copy construtor and new pointer.
Definition: CollectorMap.h:242