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 {
430 template <
typename K,
typename T,
431 template <
class>
class ComparePolicy = SimpleCompare,
433 template <
class>
class CopyPolicy = DefaultCopy
489 _keyPolicy = cmap._keyPolicy;
491 for(cItr = cmap._list.begin() ; cItr != cmap._list.end() ; cItr++) {
492 _list.insert(std::make_pair(cItr->first, cmap.copy(cItr->second)));
514 _keyPolicy = cmap._keyPolicy;
516 for(cItr = cmap._list.begin() ; cItr != cmap._list.end() ; cItr++) {
517 _list.insert(std::make_pair(cItr->first, cmap.copy(cItr->second)));
529 return (_list.size());
543 return (_list.count(
key));
558 _list.insert(std::make_pair(
key, value));
569 return (cItr != _list.end());
585 if(cItr == _list.end()) {
586 QString mess =
"Requested value does not exist!";
589 return (cItr->second);
599 const T &
get(
const K &
key)
const {
601 if(cItr == _list.end()) {
602 QString mess =
"Requested value does not exist!";
605 return (cItr->second);
622 if(cItr == _list.end()) {
626 return (std::distance(_list.begin(), cItr));
643 for(cItr = _list.begin(), i = 0 ; cItr != _list.end() ; ++cItr, i++) {
647 if(cItr == _list.end()) {
648 std::ostringstream mess;
649 mess <<
"Requested index (" << nth <<
") out of range" << std::endl;
652 return (cItr->second);
668 for(cItr = _list.begin(), i = 0 ; cItr != _list.end() ; ++cItr, i++) {
671 if(cItr == _list.end()) {
672 std::ostringstream mess;
673 mess <<
"Requested index (" << nth <<
") out of range" << std::endl;
676 return (cItr->second);
689 const K &
key(
int nth)
const {
692 for(cItr = _list.begin(), i = 0 ; cItr != _list.end() ; ++cItr, i++) {
695 if(cItr == _list.end()) {
696 std::ostringstream mess;
697 mess <<
"Requested key index (" << nth <<
") out of range" << std::endl;
700 return (cItr->first);
710 int remove(
const K &
key) {
712 if(Itr1 == _list.end())
return (0);
715 while(Itr1 != Itr2) {
716 this->destroy(&Itr1->second);
719 return (_list.erase(
key));
728 return _list.begin();
746 return _list.begin();
770 void selfDestruct() {
772 for(itr = _list.begin() ; itr != _list.end() ; itr++) {
773 this->destroy(&itr->second);
CollectorMap(const KeyPolicy &keyPolicy)
Allows the user to choose if keys can be duplicated.
Definition: CollectorMap.h:468
const T & copy(const T &src) const
Returns a copy of the input.
Definition: CollectorMap.h:208
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:620
Provides a case insensitive string comparison.
Definition: CollectorMap.h:69
T & getNth(int nth)
Returns the nth value in the collection.
Definition: CollectorMap.h:640
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
bool operator()(const K &v1, const K &v2) const
Compares v1 and v2 as floating point values.
Definition: CollectorMap.h:103
Supplies a NOOP default for removal of a CollectorMap entry.
Definition: CollectorMap.h:118
CollectorList::iterator CollectorIter
CollectorList iterator type declaration.
Definition: CollectorMap.h:441
void destroy(T *element)
Destroys the CollectorMap entry.
Definition: CollectorMap.h:133
Allow duplication of keys.
Definition: CollectorMap.h:453
CollectorList::const_iterator CollectorConstIter
CollectorList constant iterator type declaration.
Definition: CollectorMap.h:443
CollectorMap()
Constructor.
Definition: CollectorMap.h:457
int size() const
Returns the size of the collection.
Definition: CollectorMap.h:528
std::multimap< K, CollectorType, ComparePolicy< K > > CollectorList
A multimap attacking a key to a CollectorType and a ComparePolicy<CollectorType>
Definition: CollectorMap.h:439
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:162
virtual ~CollectorMap()
Destructor handles removal of the elements within the collection.
Definition: CollectorMap.h:475
(Default) Policy for copying map elements
Definition: CollectorMap.h:198
int count(const K &key) const
Returns the number of keys found in the list.
Definition: CollectorMap.h:542
const K & key(int nth) const
Returns the nth key in the collection.
Definition: CollectorMap.h:689
Supplies a policy for deleting pointers that CollectorMap owns.
Definition: CollectorMap.h:150
Constrain keys to be unique.
Definition: CollectorMap.h:452
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
bool exists(const K &key) const
Checks the existance of a particular key in the list.
Definition: CollectorMap.h:567
void destroy(T *element)
Destroys the array of CollectorMaps.
Definition: CollectorMap.h:180
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:40
void add(const K &key, const T &value)
Adds the element to the list.
Definition: CollectorMap.h:556
const T & getNth(int nth) const
Returns the nth value in the collection.
Definition: CollectorMap.h:665
CollectorMap(const CollectorMap &cmap)
Copy constructor invokes the copy policy as provided by the users.
Definition: CollectorMap.h:488
CollectorIter end()
Returns the end of the list.
Definition: CollectorMap.h:755
KeyPolicy
Enumerated selection of key behaviour.
Definition: CollectorMap.h:452
Collector/container for arbitrary items.
Definition: CollectorMap.h:435
const double E
Sets some basic constants for use in ISIS programming.
Definition: Constants.h:55
CollectorConstIter end() const
Const iterator to end of list.
Definition: CollectorMap.h:736
IString DownCase()
Converts all upper case letters in the object IString into lower case characters. ...
Definition: IString.cpp:659
CollectorMap & operator=(const CollectorMap &cmap)
Assignment operator for the CollectorMap class object.
Definition: CollectorMap.h:511
T CollectorType
Data type.
Definition: CollectorMap.h:437
Isis exception class.
Definition: IException.h:107
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
bool operator()(const K &v1, const K &v2) const
Returns true if v1 is less than v2.
Definition: CollectorMap.h:56
CollectorIter begin()
Returns the start of the list for iterating purposes.
Definition: CollectorMap.h:745
Provides a simple comparison between two values.
Definition: CollectorMap.h:46
Pointer to object policy for copying map elements.
Definition: CollectorMap.h:230
CollectorConstIter begin() const
Const iterator into list.
Definition: CollectorMap.h:727
T copy(const T &src) const
Allocate new object using copy construtor and new pointer.
Definition: CollectorMap.h:242