00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef VRS_MULTIDICTIONARY_H
00019 #define VRS_MULTIDICTIONARY_H
00020
00021 #include <vrs/container/array.h>
00022 #include <vrs/container/dictionary.h>
00023
00024 namespace VRS {
00025
00027 template<typename K, typename V>
00028 class NonPersistentMultiDictionary : public SharedObj {
00029 public:
00030 NonPersistentMultiDictionary(unsigned int estimatedElements = 0, bool autoDeleteKey = true);
00035
00036
00037
00038
00039
00040
00041
00042
00043 void setValue(const K& key, SO<Array<V> >value);
00044 SO<Array<V> > getValue(const K& key) const;
00045
00046 bool find(const K& key, V& result) const;
00052 bool contains(const K& key) const;
00056 int size(void) const;
00058
00059 bool isEmpty(void) const;
00061
00062 bool insert(const K& key, const V& v);
00063 bool erase( const K& k, const V& v);
00064 bool erase(const K& key);
00065 void clear(void);
00074 Iterator<K>* newKeyIterator(void) const;
00076
00077 Iterator<V>* newValueIterator(const K&) const;
00079
00080
00081 inline void setAutoDeleteKey(bool autoDeleteKey)
00082 {
00083 if(this->autoDeleteKey_ != autoDeleteKey)
00084 {
00085 this->autoDeleteKey_ = autoDeleteKey;
00086 modified();
00087
00088 }
00089 return;
00090 }
00091
00092 inline bool getAutoDeleteKey(void) const
00093 {
00094 return this->autoDeleteKey_;
00095 }
00096
00097
00098 VRS_TYPEINFO(NonPersistentMultiDictionary, SharedObj);
00099 VRS_SERIALIZABLE_ABSTRACT_CLASS(NonPersistentMultiDictionary);
00100
00101 private:
00102
00103 SO<Dictionary<K, SO<Array<V> > > > multiMap_;
00104 bool autoDeleteKey_;
00105
00106 };
00107
00108
00109 template<typename K, typename V>
00110 class MultiDictionary : public NonPersistentMultiDictionary<K, V>
00111 {
00112
00113 public:
00114 MultiDictionary(unsigned int estimatedElements = 0, bool autoDeleteKey = true) :
00115 NonPersistentMultiDictionary<K, V>(estimatedElements, autoDeleteKey) { }
00116
00117 VRS_TYPEINFO(MultiDictionary, VRS_TEMPLATE_ARGS_2(K, V, NonPersistentMultiDictionary));
00118 VRS_SERIALIZABLE(MultiDictionary);
00119 };
00120
00121 VRS_SERIALIZATION_REGISTRATION_TEMPLATE_2(MultiDictionary);
00122
00123 }
00124
00125 #include <vrs/container/multidictionary.tli>
00126
00127 #endif // VRS_MULTIDICTIONARY_H