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);
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>
boost::shared_ptr< Value > & operator[](const boost::shared_ptr< Key > &k)
get object corresponding to key
Definition: CORE_SharedPointersKVMap.h:48
virtual tString toString() const
return the string representation of the object node
Definition: CORE_SharedPointersKVMap.hpp:41
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
this class describes an array
Definition: CORE_Vector.h:19
class CORE_SharedPointersList is a list of shared pointers
Definition: CORE_SharedPointersList.h:11
tUIndex getSize() const
return the size of the array
Definition: CORE_SharedPointersKVMap.h:77
CORE_SharedPointersKVMap()
Definition: CORE_SharedPointersKVMap.hpp:7
tBoolean removeValue(const Value *k)
remove the value
Definition: CORE_SharedPointersKVMap.hpp:205
void keys(CORE_SharedPointersList< Key > &ks) const
return an array of keys
Definition: CORE_SharedPointersKVMap.h:106
void getKeys(CORE_SharedPointersList< Key > &ks) const
return an array of keys
Definition: CORE_SharedPointersKVMap.hpp:148
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
map< boost::shared_ptr< Key >, boost::shared_ptr< Value > > mMap
Definition: CORE_SharedPointersKVMap.h:18
map< boost::shared_ptr< Key >, boost::shared_ptr< Value > >::iterator mIterator
Definition: CORE_SharedPointersKVMap.h:19
void copy(const CORE_SharedPointersKVMap< K, V > &mapCpy)
copy a map
Definition: CORE_SharedPointersKVMap.hpp:27
#define tBoolean
Definition: types.h:139
tBoolean hasNext() const
had next
Definition: CORE_SharedPointersKVMap.h:129
void merge(const CORE_SharedPointersKVMap< K, V > &m)
merge the map
Definition: CORE_SharedPointersKVMap.hpp:162
void next(Key *&k, Value *&v)
had next
Definition: CORE_SharedPointersKVMap.h:135
void values(CORE_SharedPointersList< Value > &vals) const
return an array of values
Definition: CORE_SharedPointersKVMap.h:81
void getValues(CORE_Vector< Value *> &vals) const
return an array of values
Definition: CORE_SharedPointersKVMap.hpp:90
#define tUIndex
Definition: types.h:126
void values(CORE_Vector< Value *> &vals) const
return an array of values
Definition: CORE_SharedPointersKVMap.h:87
tUIndex size() const
return the size of the array
Definition: CORE_SharedPointersKVMap.h:74
abstract base class for most classes.
Definition: CORE_Object.h:53
#define tString
Definition: types.h:135
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
void begin()
begin
Definition: CORE_SharedPointersKVMap.h:124
const boost::shared_ptr< Value > & operator[](const boost::shared_ptr< Key > &k) const
get object corresponding to key
Definition: CORE_SharedPointersKVMap.h:42
#define ASSERT_IN(a)
Definition: types.h:196
tBoolean exists(const boost::shared_ptr< Key > &k) const
exists return true if the key exists in map
Definition: CORE_SharedPointersKVMap.hpp:56