1 #ifndef CORE_SharedPointersListVMap_CPP
2 #define CORE_SharedPointersListVMap_CPP
6 template<
class K,
class V>
14 template<
class Key,
class Value>
15 template<
class K,
class V>
22 template<
class Key,
class Value>
27 template<
class Key,
class Value>
28 template<
class K,
class V>
34 for (
int i=0;i<n;i++) {
35 boost::shared_ptr<CORE_SharedPointersList<Value> > &listAtK=m[keys[i]];
37 copyList.copy(listAtK);
38 put((Key)keys[i],copyList);
43 template<
class Key,
class Value>
50 for (
int i=0;i<n;i++) {
54 for (
int j=0;j<p;j++) {
62 template<
class Key,
class Value>
64 typename map<Key,boost::shared_ptr<CORE_SharedPointersList<Value> > >::const_iterator iter=mMap.find(k);
65 if (iter==mMap.end())
return false;
69 template<
class Key,
class Value>
72 typename map<Key,boost::shared_ptr<CORE_SharedPointersList<Value> > >::iterator iter=mMap.find(k);
73 if (iter!=mMap.end()) {
74 boost::shared_ptr<CORE_SharedPointersList<Value> > &listAtK=iter->second;
78 template<
class Key,
class Value>
80 typename map<Key,boost::shared_ptr<CORE_SharedPointersList<Value> > >::iterator iter=mMap.find(k);
81 if (iter==mMap.end()) {
86 boost::shared_ptr<CORE_SharedPointersList<Value> > &listAtK=iter->second;
88 if (!listAtK->exists(v)) listAtK->add(v);
89 }
else listAtK->add(v);
94 template<
class Key,
class Value>
96 typename map<Key,boost::shared_ptr<CORE_SharedPointersList<Value> > >::const_iterator iter=mMap.find(k);
97 if (iter==mMap.end())
return null;
98 return iter->second.get();
101 template<
class Key,
class Value>
103 typename map<Key,boost::shared_ptr<CORE_SharedPointersList<Value> > >::iterator iter=mMap.find(k);
104 if (iter==mMap.end())
return null;
105 return iter->second.get();
111 template<
class Key,
class Value>
113 int nbKeys=mMap.size();
115 typename map<Key,boost::shared_ptr<CORE_SharedPointersList<Value> > >::const_iterator iter=mMap.begin();
116 typename map<Key,boost::shared_ptr<CORE_SharedPointersList<Value> > >::const_iterator end=mMap.end();
125 template<
class Key,
class Value>
128 typename map<Key,boost::shared_ptr<CORE_SharedPointersList<Value> > >::const_iterator iter=mMap.begin();
129 typename map<Key,boost::shared_ptr<CORE_SharedPointersList<Value> > >::const_iterator end=mMap.end();
132 keys.
add(iter->first);
137 template<
class Key,
class Value>
140 typename map<Key,boost::shared_ptr<CORE_SharedPointersList<Value> > >::const_iterator iter=mMap.begin();
141 typename map<Key,boost::shared_ptr<CORE_SharedPointersList<Value> > >::const_iterator end=mMap.end();
144 keys.
add(iter->first);
150 template<
class Key,
class Value>
152 typename map<Key,boost::shared_ptr<CORE_SharedPointersList<Value> > >::const_iterator exists=mMap.find(k);
153 if (exists!=mMap.end()) {
160 template<
class Key,
class Value>
166 for (
int i=0;i<n;i++) {
167 if ((*
this)[ks[i]]->exists(v)) ret=
remove(ks[i]);
172 template<
class Key,
class Value>
178 for (
int i=0;i<n;i++) {
179 if ((*
this)[ks[i]]->exists(v)) ret=
remove(ks[i]);
184 template<
class Key,
class Value>
190 for (
int i=0;i<n;i++) {
191 if ((*
this)[ks[i]]->exists(v)) ret=
remove(ks[i]);
virtual void clear()
clear the array
Definition: CORE_Array.h:489
virtual tString toString() const
return the string representation of the object node
Definition: CORE_SharedPointersListVMap.hpp:44
tString toString() const
return the string associated to the string
Definition: CORE_String.h:150
this class describes an array
Definition: CORE_Vector.h:18
class CORE_SharedPointersList is a list of shared pointers
Definition: CORE_SharedPointersList.h:11
static boost::shared_ptr< CORE_SharedPointersList< T > > New()
New constructor of a shared pointers list.
Definition: CORE_SharedPointersList.h:79
CORE_SharedPointersListVMap()
Definition: CORE_SharedPointersListVMap.hpp:7
const CORE_SharedPointersList< Value > * get(const Key &k) const
get the value at key k
Definition: CORE_SharedPointersListVMap.hpp:95
tBoolean exists(const Key &k) const
exists return true if the key exists in map
Definition: CORE_SharedPointersListVMap.hpp:63
void copy(const CORE_SharedPointersListVMap< K, V > &mapCpy)
copy a map
Definition: CORE_SharedPointersListVMap.hpp:29
virtual ~CORE_SharedPointersListVMap()
destroy a map
Definition: CORE_SharedPointersListVMap.hpp:23
#define tBoolean
Definition: types.h:35
This class describes a map: primitive type of Key -> shared pointer of list of Value.
Definition: CORE_SharedPointersListVMap.h:17
tBoolean remove(const Key &k)
remove the key
Definition: CORE_SharedPointersListVMap.hpp:151
void add(const CORE_Vector< T > &v)
init the value to v
Definition: CORE_Vector.h:206
void clear()
clear the map
Definition: CORE_SharedPointersListVMap.h:233
#define null
Definition: types.h:13
tBoolean put(const Key &k, boost::shared_ptr< CORE_SharedPointersList< Value > > v)
set the value at the index k
Definition: CORE_SharedPointersListVMap.h:129
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 an array
Definition: CORE_Array.h:18
tBoolean removeValue(const Value *k)
remove the value
Definition: CORE_SharedPointersListVMap.hpp:185
int getSize() const
return the size of the array
Definition: CORE_SharedPointersList.h:250
tString toString() const
return the string associated to the integer
Definition: CORE_Integer.h:142
abstract base class for most classes.
Definition: CORE_Object.h:30
#define tString
Definition: types.h:36
virtual tString toString() const
return the string representation of the object node
Definition: CORE_Object.cpp:101
void getKeys(vector< Key > &ks) const
return a vector of keys
Definition: CORE_SharedPointersListVMap.hpp:112
void clear()
clear the array
Definition: CORE_Vector.h:350