1 #ifndef CORE_SharedPointersVMap_CPP
2 #define CORE_SharedPointersVMap_CPP
6 template<
class K,
class V>
14 template<
class Key,
class Value>
15 template<
class K,
class V>
21 template<
class Key,
class Value>
26 template<
class Key,
class Value>
27 template<
class K,
class V>
34 put((Key)keys[i],boost::dynamic_pointer_cast<Value>(m[keys[i]]));
38 template<
class K,
class V>
44 for (
int i=0;i<n;i++) {
51 template<
class Key,
class Value>
53 typename map<Key,boost::shared_ptr<Value> >::const_iterator iter=mMap.find(k);
54 if (iter==mMap.end())
return false;
58 template<
class Key,
class Value>
60 typename map<Key,boost::shared_ptr<Value> >::const_iterator iter=mMap.find(k);
61 if (iter==mMap.end())
return null;
62 return iter->second.get();
65 template<
class Key,
class Value>
67 typename map<Key,boost::shared_ptr<Value> >::iterator iter=mMap.find(k);
68 if (iter==mMap.end())
return null;
69 return iter->second.get();
72 template<
class Key,
class Value>
77 typename map<Key,boost::shared_ptr<Value> >::const_iterator iter=mMap.begin();
78 typename map<Key,boost::shared_ptr<Value> >::const_iterator end=mMap.end();
81 vals.
set(i++,iter->second);
85 template<
class Key,
class Value>
90 typename map<Key,boost::shared_ptr<Value> >::const_iterator iter=mMap.begin();
91 typename map<Key,boost::shared_ptr<Value> >::const_iterator end=mMap.end();
94 vals.
set(i++,iter->second);
99 template<
class Key,
class Value>
104 typename map<Key,boost::shared_ptr<Value> >::const_iterator iter=mMap.begin();
105 typename map<Key,boost::shared_ptr<Value> >::const_iterator end=mMap.end();
108 vals[i++]=iter->second.
get();
112 template<
class Key,
class Value>
117 typename map<Key,boost::shared_ptr<Value> >::const_iterator iter=mMap.begin();
118 typename map<Key,boost::shared_ptr<Value> >::const_iterator end=mMap.end();
121 vals[i++]=iter->second.get();
128 template<
class Key,
class Value>
130 int nbKeys=mMap.size();
132 typename map<Key,boost::shared_ptr<Value> >::const_iterator iter=mMap.begin();
133 typename map<Key,boost::shared_ptr<Value> >::const_iterator end=mMap.end();
142 template<
class Key,
class Value>
145 typename map<Key,boost::shared_ptr<Value> >::const_iterator iter=mMap.begin();
146 typename map<Key,boost::shared_ptr<Value> >::const_iterator end=mMap.end();
149 keys.
add(iter->first);
154 template<
class Key,
class Value>
157 typename map<Key,boost::shared_ptr<Value> >::const_iterator iter=mMap.begin();
158 typename map<Key,boost::shared_ptr<Value> >::const_iterator end=mMap.end();
161 keys.
add(iter->first);
167 template<
class Key,
class Value>
168 template<
class K,
class V>
172 int nbKeys=ks.size();
173 for (
int i=0;i<nbKeys;i++) {
174 put((Key)ks[i],boost::dynamic_pointer_cast<Value>(m[ks[i]]));
178 template<
class Key,
class Value>
180 typename map<Key,boost::shared_ptr<Value> >::const_iterator exists=mMap.find(k);
181 if (exists!=mMap.end()) {
188 template<
class Key,
class Value>
194 for (
int i=0;i<n;i++) {
195 if ((*
this)[ks[i]]==v) ret=
remove(ks[i]);
200 template<
class Key,
class Value>
206 for (
int i=0;i<n;i++) {
207 if (
get(ks[i])==v) ret=
remove(ks[i]);
211 template<
class Key,
class Value>
217 for (
int i=0;i<n;i++) {
218 if (
get(ks[i])==v) ret=
remove(ks[i]);
tBoolean exists(const Key &k) const
exists return true if the key exists in map
Definition: CORE_SharedPointersVMap.hpp:52
virtual void clear()
clear the array
Definition: CORE_Array.h:489
tString toString() const
return the string associated to the string
Definition: CORE_String.h:150
void copy(const CORE_SharedPointersVMap< K, V > &mapCpy)
copy a map
Definition: CORE_SharedPointersVMap.hpp:28
this class describes an array
Definition: CORE_Vector.h:18
class CORE_SharedPointersList is a list of shared pointers
Definition: CORE_SharedPointersList.h:11
void clear()
clear the array
Definition: CORE_SharedPointersList.h:206
tBoolean remove(const Key &k)
remove the key
Definition: CORE_SharedPointersVMap.hpp:179
#define tBoolean
Definition: types.h:35
void getKeys(vector< Key > &ks) const
return a vector of keys
Definition: CORE_SharedPointersVMap.hpp:129
virtual tString toString() const
return the string representation of the object node
Definition: CORE_SharedPointersVMap.hpp:39
void getValues(CORE_Vector< Value * > &vals) const
return an array of values
Definition: CORE_SharedPointersVMap.hpp:100
void add(const CORE_Vector< T > &v)
init the value to v
Definition: CORE_Vector.h:206
void setSize(const int &n)
set the size of the shared pointers list
Definition: CORE_SharedPointersList.h:94
#define null
Definition: types.h:13
void add(const T &obj)
add an element at the end re-allocate the array if capacity too small
Definition: CORE_Array.hpp:157
This class describes a map: primitive type of Key -> shared pointer of Value.
Definition: CORE_SharedPointersVMap.h:15
virtual ~CORE_SharedPointersVMap()
destroy a map
Definition: CORE_SharedPointersVMap.hpp:22
this class describes an array
Definition: CORE_Array.h:18
void merge(const CORE_SharedPointersVMap< K, V > &m)
merge the map
Definition: CORE_SharedPointersVMap.hpp:169
const Value * get(const Key &k) const
get the value at key k
Definition: CORE_SharedPointersVMap.hpp:59
abstract base class for most classes.
Definition: CORE_Object.h:30
tBoolean removeValue(const Value *k)
remove the value
Definition: CORE_SharedPointersVMap.hpp:212
#define tString
Definition: types.h:36
const T & get(int i) const
get the pointer at index i ASSERT_IN(i>-1); ASSERT_IN(i<((int)mVector.size()));
Definition: CORE_Vector.h:367
void setSize(const int &n)
set the size of the array
Definition: CORE_Vector.h:162
CORE_SharedPointersVMap()
Definition: CORE_SharedPointersVMap.hpp:7
virtual tString toString() const
return the string representation of the object node
Definition: CORE_Object.cpp:101
tBoolean set(const int &i, const boost::shared_ptr< T > &obj)
set the pointer at the index i
Definition: CORE_SharedPointersList.hpp:127
void clear()
clear the array
Definition: CORE_Vector.h:350
#define tInteger
Definition: types.h:32