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 {
254 template <
typename P>
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;
489 for(cItr = cmap.
_list.begin() ; cItr != cmap.
_list.end() ; cItr++) {
490 _list.insert(std::make_pair(cItr->first, cmap.copy(cItr->second)));
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);
722 return _list.begin();
740 return _list.begin();
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.
const K & key(int nth) const
Returns the nth key in the collection.
bool exists(const K &key) const
Checks the existance of a particular key in the list.
const double E(2.7182818284590452354)
Sets some basic constants for use in ISIS programming.
Policy for deleting arrays that CollectorMap owns.
int index(const K &key) const
Returns the index of the first occuring element in the list.
Provides a case insensitive string comparison.
T & getNth(int nth)
Returns the nth value in the collection.
CollectorConstIter begin() const
Const iterator into list.
void destroy(T *element)
Destroys the CollectorMap pointer's CollectorMap.
Provides a robust comparison of double/float values.
Supplies a NOOP default for removal of a CollectorMap entry.
CollectorList::iterator CollectorIter
CollectorList iterator type declaration.
void destroy(T *element)
Destroys the CollectorMap entry.
Allow duplication of keys.
CollectorList::const_iterator CollectorConstIter
CollectorList constant iterator type declaration.
CollectorMap()
Constructor.
This error is for when a programmer made an API call that was illegal.
virtual ~CollectorMap()
Destructor handles removal of the elements within the collection.
const T & getNth(int nth) const
Returns the nth value in the collection.
KeyPolicy _keyPolicy
Unique or duplicate key constraint.
(Default) Policy for copying map elements
Supplies a policy for deleting pointers that CollectorMap owns.
Constrain keys to be unique.
void destroy(T *element)
Destroys the array of CollectorMaps.
int count(const K &key) const
Returns the number of keys found in the list.
#define _FILEINFO_
Macro for the filename and line number.
void add(const K &key, const T &value)
Adds the element to the list.
CollectorMap(const CollectorMap &cmap)
Copy constructor invokes the copy policy as provided by the users.
CollectorIter end()
Returns the end of the list.
bool operator()(const K &v1, const K &v2) const
Returns true if v1 is less than v2.
KeyPolicy
Enumerated selection of key behaviour.
CollectorList _list
The list.
Collector/container for arbitrary items.
IString DownCase()
Converts all upper case letters in the object IString into lower case characters. ...
CollectorConstIter end() const
Const iterator to end of list.
const T & copy(const T &src) const
Returns a copy of the input.
CollectorMap & operator=(const CollectorMap &cmap)
Assignment operator for the CollectorMap class object.
T CollectorType
Data type A multimap attacking a key t...
int size() const
Returns the size of the collection.
void selfDestruct()
Thourough destruction of list.
bool operator()(const K &v1, const K &v2) const
Compares v1 and v2 as floating point values.
P * allocate(const P &obj) const
Allocate new object using copy constructor.
CollectorIter begin()
Returns the start of the list for iterating purposes.
Provides a simple comparison between two values.
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...
Pointer to object policy for copying map elements.
T copy(const T &src) const
Allocate new object using copy construtor and new pointer.