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>
430 template <
typename K,
typename T,
431 template <
class>
class ComparePolicy = SimpleCompare,
433 template <
class>
class CopyPolicy = DefaultCopy
491 for(cItr = cmap.
_list.begin() ; cItr != cmap.
_list.end() ; cItr++) {
492 _list.insert(std::make_pair(cItr->first, cmap.copy(cItr->second)));
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());
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);
728 return _list.begin();
746 return _list.begin();
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.
const T & copy(const T &src) const
Returns a copy of the input.
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.
void destroy(T *element)
Destroys the CollectorMap pointer's CollectorMap.
Provides a robust comparison of double/float values.
bool operator()(const K &v1, const K &v2) const
Compares v1 and v2 as floating point 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.
int size() const
Returns the size of the collection.
std::multimap< K, CollectorType, ComparePolicy< K > > CollectorList
A multimap attacking a key to a CollectorType and a ComparePolicy<CollectorType>
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.
KeyPolicy _keyPolicy
Unique or duplicate key constraint.
(Default) Policy for copying map elements
P * allocate(const P &obj) const
Allocate new object using copy constructor.
int count(const K &key) const
Returns the number of keys found in the list.
const K & key(int nth) const
Returns the nth key in the collection.
Supplies a policy for deleting pointers that CollectorMap owns.
Constrain keys to be unique.
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...
bool exists(const K &key) const
Checks the existance of a particular key in the list.
void destroy(T *element)
Destroys the array of CollectorMaps.
#define _FILEINFO_
Macro for the filename and line number.
void add(const K &key, const T &value)
Adds the element to the list.
const T & getNth(int nth) const
Returns the nth value in the collection.
CollectorMap(const CollectorMap &cmap)
Copy constructor invokes the copy policy as provided by the users.
CollectorIter end()
Returns the end of the list.
KeyPolicy
Enumerated selection of key behaviour.
CollectorList _list
The list.
Collector/container for arbitrary items.
const double E
Sets some basic constants for use in ISIS programming.
CollectorConstIter end() const
Const iterator to end of list.
IString DownCase()
Converts all upper case letters in the object IString into lower case characters. ...
CollectorMap & operator=(const CollectorMap &cmap)
Assignment operator for the CollectorMap class object.
T CollectorType
Data type.
Namespace for ISIS/Bullet specific routines.
void selfDestruct()
Thourough destruction of list.
bool operator()(const K &v1, const K &v2) const
Returns true if v1 is less than v2.
CollectorIter begin()
Returns the start of the list for iterating purposes.
Provides a simple comparison between two values.
Pointer to object policy for copying map elements.
CollectorConstIter begin() const
Const iterator into list.
T copy(const T &src) const
Allocate new object using copy construtor and new pointer.