19#include <gsl/gsl_math.h>
88 return (gsl_fcmp(v1, v2, -1.0E-6) < 0);
192 const T &
copy(
const T &src)
const {
227 return (allocate(*(src)));
238 template <
typename P>
239 P *allocate(
const P &obj)
const {
414 template <
typename K,
typename T,
415 template <
class>
class ComparePolicy = SimpleCompare,
416 template <
class>
class RemovalPolicy = NoopRemoval,
417 template <
class>
class CopyPolicy = DefaultCopy
473 _keyPolicy = cmap._keyPolicy;
475 for(cItr = cmap._list.begin() ; cItr != cmap._list.end() ; cItr++) {
476 _list.insert(std::make_pair(cItr->first, cmap.copy(cItr->second)));
498 _keyPolicy = cmap._keyPolicy;
500 for(cItr = cmap._list.begin() ; cItr != cmap._list.end() ; cItr++) {
501 _list.insert(std::make_pair(cItr->first, cmap.copy(cItr->second)));
513 return (_list.size());
527 return (_list.count(
key));
542 _list.insert(std::make_pair(
key, value));
553 return (cItr != _list.end());
569 if(cItr == _list.end()) {
570 QString mess =
"Requested value does not exist!";
573 return (cItr->second);
585 if(cItr == _list.end()) {
586 QString mess =
"Requested value does not exist!";
589 return (cItr->second);
606 if(cItr == _list.end()) {
610 return (std::distance(_list.begin(), cItr));
627 for(cItr = _list.begin(), i = 0 ; cItr != _list.end() ; ++cItr, i++) {
631 if(cItr == _list.end()) {
632 std::ostringstream mess;
633 mess <<
"Requested index (" << nth <<
") out of range" << std::endl;
636 return (cItr->second);
652 for(cItr = _list.begin(), i = 0 ; cItr != _list.end() ; ++cItr, i++) {
655 if(cItr == _list.end()) {
656 std::ostringstream mess;
657 mess <<
"Requested index (" << nth <<
") out of range" << std::endl;
660 return (cItr->second);
673 const K &
key(
int nth)
const {
676 for(cItr = _list.begin(), i = 0 ; cItr != _list.end() ; ++cItr, i++) {
679 if(cItr == _list.end()) {
680 std::ostringstream mess;
681 mess <<
"Requested key index (" << nth <<
") out of range" << std::endl;
684 return (cItr->first);
696 if(Itr1 == _list.end())
return (0);
699 while(Itr1 != Itr2) {
700 this->destroy(&Itr1->second);
703 return (_list.erase(
key));
712 return _list.begin();
730 return _list.begin();
744 KeyPolicy _keyPolicy;
754 void selfDestruct() {
756 for(itr = _list.begin() ; itr != _list.end() ; itr++) {
757 this->destroy(&itr->second);
#define _FILEINFO_
Macro for the filename and line number.
Definition IException.h:24
Collector/container for arbitrary items.
Definition CollectorMap.h:419
const K & key(int nth) const
Returns the nth key in the collection.
Definition CollectorMap.h:673
virtual ~CollectorMap()
Destructor handles removal of the elements within the collection.
Definition CollectorMap.h:459
CollectorMap & operator=(const CollectorMap &cmap)
Assignment operator for the CollectorMap class object.
Definition CollectorMap.h:495
int size() const
Returns the size of the collection.
Definition CollectorMap.h:512
std::multimap< K, CollectorType, ComparePolicy< K > > CollectorList
A multimap attacking a key to a CollectorType and a ComparePolicy<CollectorType>
Definition CollectorMap.h:423
CollectorList::const_iterator CollectorConstIter
CollectorList constant iterator type declaration.
Definition CollectorMap.h:427
int remove(const K &key)
Removes and entry from the list.
Definition CollectorMap.h:694
CollectorMap()
Constructor.
Definition CollectorMap.h:441
T & get(const K &key)
Returns the value associated with the name provided.
Definition CollectorMap.h:567
bool exists(const K &key) const
Checks the existance of a particular key in the list.
Definition CollectorMap.h:551
KeyPolicy
Enumerated selection of key behaviour.
Definition CollectorMap.h:436
@ UniqueKeys
Constrain keys to be unique.
Definition CollectorMap.h:436
@ DuplicateKeys
Allow duplication of keys.
Definition CollectorMap.h:437
CollectorMap(const KeyPolicy &keyPolicy)
Allows the user to choose if keys can be duplicated.
Definition CollectorMap.h:452
int index(const K &key) const
Returns the index of the first occuring element in the list.
Definition CollectorMap.h:604
CollectorIter end()
Returns the end of the list.
Definition CollectorMap.h:739
const T & get(const K &key) const
Const version returning the value associated with the given name.
Definition CollectorMap.h:583
CollectorIter begin()
Returns the start of the list for iterating purposes.
Definition CollectorMap.h:729
const T & getNth(int nth) const
Returns the nth value in the collection.
Definition CollectorMap.h:649
CollectorConstIter begin() const
Const iterator into list.
Definition CollectorMap.h:711
CollectorConstIter end() const
Const iterator to end of list.
Definition CollectorMap.h:720
CollectorMap(const CollectorMap &cmap)
Copy constructor invokes the copy policy as provided by the users.
Definition CollectorMap.h:472
T CollectorType
Data type.
Definition CollectorMap.h:421
void add(const K &key, const T &value)
Adds the element to the list.
Definition CollectorMap.h:540
int count(const K &key) const
Returns the number of keys found in the list.
Definition CollectorMap.h:526
T & getNth(int nth)
Returns the nth value in the collection.
Definition CollectorMap.h:624
CollectorList::iterator CollectorIter
CollectorList iterator type declaration.
Definition CollectorMap.h:425
Isis exception class.
Definition IException.h:91
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition IException.h:146
IString DownCase()
Converts all upper case letters in the object IString into lower case characters.
Definition IString.cpp:644
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
Policy for deleting arrays that CollectorMap owns.
Definition CollectorMap.h:156
void destroy(T *element)
Destroys the array of CollectorMaps.
Definition CollectorMap.h:164
(Default) Policy for copying map elements
Definition CollectorMap.h:182
const T & copy(const T &src) const
Returns a copy of the input.
Definition CollectorMap.h:192
Provides a case insensitive string comparison.
Definition CollectorMap.h:53
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:64
Supplies a NOOP default for removal of a CollectorMap entry.
Definition CollectorMap.h:102
void destroy(T *element)
Destroys the CollectorMap entry.
Definition CollectorMap.h:117
Pointer to object policy for copying map elements.
Definition CollectorMap.h:214
T copy(const T &src) const
Allocate new object using copy construtor and new pointer.
Definition CollectorMap.h:226
Supplies a policy for deleting pointers that CollectorMap owns.
Definition CollectorMap.h:134
void destroy(T *element)
Destroys the CollectorMap pointer's CollectorMap.
Definition CollectorMap.h:142
Provides a robust comparison of double/float values.
Definition CollectorMap.h:77
bool operator()(const K &v1, const K &v2) const
Compares v1 and v2 as floating point values.
Definition CollectorMap.h:87
Provides a simple comparison between two values.
Definition CollectorMap.h:30
bool operator()(const K &v1, const K &v2) const
Returns true if v1 is less than v2.
Definition CollectorMap.h:40