1 #ifndef CORE_SharedPointersKVMap_H
2 #define CORE_SharedPointersKVMap_H
4 #include "boost/shared_ptr.hpp"
5 #include "boost/weak_ptr.hpp"
15 template <
class Key,
class Value>
18 map<boost::shared_ptr<Key>,boost::shared_ptr<Value> > mMap;
19 typename map<boost::shared_ptr<Key>,boost::shared_ptr<Value> >::iterator mIterator;
31 template <
class K,
class Q>
42 inline const boost::shared_ptr<Value>&
operator[](
const boost::shared_ptr<Key>& k)
const {
44 return mMap.find(k)->second;
48 inline boost::shared_ptr<Value>&
operator[](
const boost::shared_ptr<Key>& k) {
50 return mMap.find(k)->second;
66 const Value*
get(
const boost::shared_ptr<Key>& k)
const;
71 Value*
get(
const boost::shared_ptr<Key>& k);
74 inline int size()
const{
return (
int) mMap.size();};
77 inline int getSize()
const{
return (
int) mMap.size();};
96 void getValues(vector<Value*>& vals)
const;
116 void getKeys(vector<Key*>& ks)
const;
125 mIterator=mMap.begin();
130 return (mIterator!=mMap.end());
135 inline void next(Key*& k,Value*& v) {
136 v=mIterator->second.get();
137 k=mIterator->first.get();
146 template<
class K,
class V>
152 inline void put(
const boost::shared_ptr<const Key>& k,
153 const boost::shared_ptr<const Value>& v) {
159 inline void put(
const boost::shared_ptr<Key>& k,
const boost::shared_ptr<Value>& v) {
171 tBoolean remove(
const boost::shared_ptr<Key>& k);
208 template <
class K,
class V>
void values(CORE_SharedPointersList< Value > &vals) const
return an array of values
Definition: CORE_SharedPointersKVMap.h:81
boost::shared_ptr< Value > & operator[](const boost::shared_ptr< Key > &k)
get object corresponding to key
Definition: CORE_SharedPointersKVMap.h:48
tBoolean exists(const boost::shared_ptr< Key > &k) const
exists return true if the key exists in map
Definition: CORE_SharedPointersKVMap.hpp:54
void put(const boost::shared_ptr< const Key > &k, const boost::shared_ptr< const Value > &v)
set the value at the index k
Definition: CORE_SharedPointersKVMap.h:152
tBoolean hasNext() const
had next
Definition: CORE_SharedPointersKVMap.h:129
void keys(CORE_SharedPointersList< Key > &ks) const
return an array of keys
Definition: CORE_SharedPointersKVMap.h:106
this class describes an array
Definition: CORE_Vector.h:18
class CORE_SharedPointersList is a list of shared pointers
Definition: CORE_SharedPointersList.h:11
CORE_SharedPointersKVMap()
Definition: CORE_SharedPointersKVMap.hpp:7
tBoolean removeValue(const Value *k)
remove the value
Definition: CORE_SharedPointersKVMap.hpp:201
const boost::shared_ptr< Value > & operator[](const boost::shared_ptr< Key > &k) const
get object corresponding to key
Definition: CORE_SharedPointersKVMap.h:42
void clear()
clear the map
Definition: CORE_SharedPointersKVMap.h:197
This class describes a map: shared pointer of Key -> shared pointer of Value.
Definition: CORE_SharedPointersKVMap.h:16
void copy(const CORE_SharedPointersKVMap< K, V > &mapCpy)
copy a map
Definition: CORE_SharedPointersKVMap.hpp:27
#define tBoolean
Definition: types.h:35
void getKeys(CORE_SharedPointersList< Key > &ks) const
return an array of keys
Definition: CORE_SharedPointersKVMap.hpp:145
void merge(const CORE_SharedPointersKVMap< K, V > &m)
merge the map
Definition: CORE_SharedPointersKVMap.hpp:158
void next(Key *&k, Value *&v)
had next
Definition: CORE_SharedPointersKVMap.h:135
void getValues(CORE_Vector< Value * > &vals) const
return an array of values
Definition: CORE_SharedPointersKVMap.hpp:88
int getSize() const
return the size of the array
Definition: CORE_SharedPointersKVMap.h:77
abstract base class for most classes.
Definition: CORE_Object.h:30
#define tString
Definition: types.h:36
void put(const boost::shared_ptr< Key > &k, const boost::shared_ptr< Value > &v)
set the value at the index k
Definition: CORE_SharedPointersKVMap.h:159
virtual ~CORE_SharedPointersKVMap()
destroy a map
Definition: CORE_SharedPointersKVMap.hpp:20
int size() const
return the size of the array
Definition: CORE_SharedPointersKVMap.h:74
void begin()
begin
Definition: CORE_SharedPointersKVMap.h:124
void values(CORE_Vector< Value * > &vals) const
return an array of values
Definition: CORE_SharedPointersKVMap.h:87
virtual tString toString() const
return the string representation of the object node
Definition: CORE_SharedPointersKVMap.hpp:39
#define ASSERT_IN(a)
Definition: types.h:82