1 #ifndef CORE_SharedPointersKVMap_CPP 2 #define CORE_SharedPointersKVMap_CPP 6 template<
class K,
class V>
13 template<
class Key,
class Value>
14 template<
class K,
class V>
19 template<
class Key,
class Value>
25 template<
class Key,
class Value>
26 template<
class K,
class V>
29 vector<boost::shared_ptr<K> >
keys;
31 typename vector<boost::shared_ptr<K> >::iterator iKeys=keys.begin();
32 while (iKeys!=keys.end()) {
33 put(boost::dynamic_pointer_cast<Key>(*iKeys),boost::dynamic_pointer_cast<Value> (m[*iKeys]));
40 template<
class K,
class V>
55 template<
class Key,
class Value>
57 typename map<boost::shared_ptr<Key>,boost::shared_ptr<Value> >::const_iterator iter=
mMap.find(k);
58 if (iter==
mMap.end())
return false;
62 template<
class Key,
class Value>
64 typename map<boost::shared_ptr<Key>,boost::shared_ptr<Value> >::const_iterator iter=
mMap.find(k);
66 return iter->second.get();
69 template<
class Key,
class Value>
71 typename map<boost::shared_ptr<Key>,boost::shared_ptr<Value> >::iterator iter=
mMap.find(k);
73 return iter->second.get();
76 template<
class Key,
class Value>
81 typename map<boost::shared_ptr<Key>,boost::shared_ptr<Value> >::const_iterator iter=
mMap.begin();
82 typename map<boost::shared_ptr<Key>,boost::shared_ptr<Value> >::const_iterator end=
mMap.end();
85 vals.
set(i++,iter->second);
89 template<
class Key,
class Value>
94 typename map<boost::shared_ptr<Key>,boost::shared_ptr<Value> >::const_iterator iter=
mMap.begin();
95 typename map<boost::shared_ptr<Key>,boost::shared_ptr<Value> >::const_iterator end=
mMap.end();
98 vals[i++]=iter->second.
get();
102 template<
class Key,
class Value>
107 typename map<boost::shared_ptr<Key>,boost::shared_ptr<Value> >::const_iterator iter=
mMap.begin();
108 typename map<boost::shared_ptr<Key>,boost::shared_ptr<Value> >::const_iterator end=
mMap.end();
111 vals[i++]=iter->second.get();
118 template<
class Key,
class Value>
120 keys.resize(
mMap.size());
121 typename map<boost::shared_ptr<Key>,boost::shared_ptr<Value> >::const_iterator iter=
mMap.begin();
122 typename map<boost::shared_ptr<Key>,boost::shared_ptr<Value> >::const_iterator end=
mMap.end();
123 typename vector<Key*>::iterator iKeys=keys.begin();
132 template<
class Key,
class Value>
136 typename map<boost::shared_ptr<Key>,boost::shared_ptr<Value> >::const_iterator iter=
mMap.begin();
137 typename map<boost::shared_ptr<Key>,boost::shared_ptr<Value> >::const_iterator end=
mMap.end();
147 template<
class Key,
class Value>
150 typename map<boost::shared_ptr<Key>,boost::shared_ptr<Value> >::const_iterator iter=
mMap.begin();
151 typename map<boost::shared_ptr<Key>,boost::shared_ptr<Value> >::const_iterator end=
mMap.end();
154 keys.
add(iter->first);
160 template<
class Key,
class Value>
161 template<
class K,
class V>
166 for (i=0;i<nbKeys;i++) {
167 put(boost::dynamic_pointer_cast<Key>(ks[i]),boost::dynamic_pointer_cast<Value>(m[ks[i]]));
171 template<
class Key,
class Value>
173 typename map<boost::shared_ptr<Key>,boost::shared_ptr<Value> >::const_iterator
exists=
mMap.find(k);
174 if (exists!=
mMap.end()) {
181 template<
class Key,
class Value>
188 if ((*
this)[ks[i]]==v) ret=
remove(ks[i]);
193 template<
class Key,
class Value>
200 if (
get(ks[i])==v) ret=
remove(ks[i]);
204 template<
class Key,
class Value>
211 if (
get(ks[i])==v) ret=
remove(ks[i]);
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
tBoolean set(const tUIndex &i, boost::shared_ptr< T > obj)
set the pointer at the index i
Definition: CORE_SharedPointersList.hpp:95
this class describes an array
Definition: CORE_Vector.h:19
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:205
void clear()
clear the array
Definition: CORE_SharedPointersList.h:221
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
void add(boost::shared_ptr< T > obj)
add an element at the end
Definition: CORE_SharedPointersList.h:134
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
void copy(const CORE_SharedPointersKVMap< K, V > &mapCpy)
copy a map
Definition: CORE_SharedPointersKVMap.hpp:27
#define tBoolean
Definition: types.h:139
void merge(const CORE_SharedPointersKVMap< K, V > &m)
merge the map
Definition: CORE_SharedPointersKVMap.hpp:162
#define null
Definition: types.h:144
void setSize(const tUIndex &n)
set the size of the vector
Definition: CORE_Vector.h:255
const Value * get(const boost::shared_ptr< Key > &k) const
get the value at key k
Definition: CORE_SharedPointersKVMap.hpp:63
void getValues(CORE_Vector< Value *> &vals) const
return an array of values
Definition: CORE_SharedPointersKVMap.hpp:90
#define tUIndex
Definition: types.h:126
abstract base class for most classes.
Definition: CORE_Object.h:53
#define tString
Definition: types.h:135
virtual tString toString() const
return the string representation of the object node
Definition: CORE_Object.h:326
tBoolean remove(const boost::shared_ptr< Key > &k)
remove the key
Definition: CORE_SharedPointersKVMap.hpp:172
tUIndex size() const
return the size of the array
Definition: CORE_SharedPointersList.h:255
virtual ~CORE_SharedPointersKVMap()
destroy a map
Definition: CORE_SharedPointersKVMap.hpp:20
const T & get(const tUIndex &i) const
get the value at index i
Definition: CORE_Vector.h:376
void setSize(const tUIndex &n)
set the size of the shared pointers list
Definition: CORE_SharedPointersList.h:87
void clear()
clear the array
Definition: CORE_Vector.h:248
tBoolean exists(const boost::shared_ptr< Key > &k) const
exists return true if the key exists in map
Definition: CORE_SharedPointersKVMap.hpp:56