activemq-cpp-3.9.5
StlMap.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef _DECAF_UTIL_STLMAP_H_
19 #define _DECAF_UTIL_STLMAP_H_
20 
21 #include <map>
22 #include <memory>
23 #include <decaf/lang/Pointer.h>
27 #include <decaf/util/AbstractSet.h>
32 #include <decaf/util/Map.h>
33 #include <decaf/util/Collection.h>
34 #include <decaf/util/Set.h>
35 #include <decaf/util/Iterator.h>
36 
37 namespace decaf{
38 namespace util{
39 
47  template <typename K, typename V, typename COMPARATOR = decaf::util::comparators::Less<K> >
48  class StlMap : public Map<K, V> {
49  private:
50 
51  std::map<K,V,COMPARATOR> valueMap;
52  mutable concurrent::Mutex mutex;
53  int modCount;
54 
55  private:
56 
57  class AbstractMapIterator {
58  protected:
59 
60  mutable int position;
61  int expectedModCount;
62  typename std::map<K,V,COMPARATOR>::iterator futureEntry;
63  typename std::map<K,V,COMPARATOR>::iterator currentEntry;
64 
65  StlMap* associatedMap;
66 
67  private:
68 
69  AbstractMapIterator(const AbstractMapIterator&);
70  AbstractMapIterator& operator= (const AbstractMapIterator&);
71 
72  public:
73 
74  AbstractMapIterator(StlMap* parent) : position(0),
75  expectedModCount(parent->modCount),
76  futureEntry(parent->valueMap.begin()),
77  currentEntry(parent->valueMap.end()),
78  associatedMap(parent) {
79  }
80 
81  virtual ~AbstractMapIterator() {}
82 
83  virtual bool checkHasNext() const {
84  if (futureEntry != this->associatedMap->valueMap.end()) {
85  return true;
86  }
87  return false;
88  }
89 
90  void checkConcurrentMod() const {
91  if (expectedModCount != this->associatedMap->modCount) {
93  __FILE__, __LINE__, "StlMap modified outside this iterator");
94  }
95  }
96 
97  void makeNext() {
98  checkConcurrentMod();
99 
100  if (!checkHasNext()) {
101  throw NoSuchElementException(__FILE__, __LINE__, "No next element");
102  }
103 
104  currentEntry = futureEntry;
105  futureEntry++;
106  }
107 
108  virtual void doRemove() {
109 
110  checkConcurrentMod();
111 
112  if (currentEntry == this->associatedMap->valueMap.end()) {
114  __FILE__, __LINE__, "Remove called before call to next()");
115  }
116 
117  this->associatedMap->valueMap.erase(currentEntry);
118  currentEntry = this->associatedMap->valueMap.end();
119 
120  expectedModCount++;
121  associatedMap->modCount++;
122  }
123  };
124 
125  class EntryIterator : public Iterator< MapEntry<K,V> >, public AbstractMapIterator {
126  private:
127 
128  EntryIterator(const EntryIterator&);
129  EntryIterator& operator= (const EntryIterator&);
130 
131  public:
132 
133  EntryIterator(StlMap* parent) : AbstractMapIterator(parent) {}
134 
135  virtual ~EntryIterator() {}
136 
137  virtual bool hasNext() const {
138  return this->checkHasNext();
139  }
140 
141  virtual MapEntry<K, V> next() {
142  this->makeNext();
143  return MapEntry<K, V>(this->currentEntry->first, this->currentEntry->second);
144  }
145 
146  virtual void remove() {
147  this->doRemove();
148  }
149  };
150 
151  class KeyIterator : public Iterator<K>, public AbstractMapIterator {
152  private:
153 
154  KeyIterator(const KeyIterator&);
155  KeyIterator& operator= (const KeyIterator&);
156 
157  public:
158 
159  KeyIterator(StlMap* parent) : AbstractMapIterator(parent) {}
160 
161  virtual ~KeyIterator() {}
162 
163  virtual bool hasNext() const {
164  return this->checkHasNext();
165  }
166 
167  virtual K next() {
168  this->makeNext();
169  return this->currentEntry->first;
170  }
171 
172  virtual void remove() {
173  this->doRemove();
174  }
175  };
176 
177  class ValueIterator : public Iterator<V>, public AbstractMapIterator {
178  private:
179 
180  ValueIterator(const ValueIterator&);
181  ValueIterator& operator= (const ValueIterator&);
182 
183  public:
184 
185  ValueIterator(StlMap* parent) : AbstractMapIterator(parent) {
186  }
187 
188  virtual ~ValueIterator() {}
189 
190  virtual bool hasNext() const {
191  return this->checkHasNext();
192  }
193 
194  virtual V next() {
195  this->makeNext();
196  return this->currentEntry->second;
197  }
198 
199  virtual void remove() {
200  this->doRemove();
201  }
202  };
203 
204  private:
205 
206  class ConstAbstractMapIterator {
207  protected:
208 
209  mutable int position;
210  int expectedModCount;
211  typename std::map<K,V,COMPARATOR>::const_iterator futureEntry;
212  typename std::map<K,V,COMPARATOR>::const_iterator currentEntry;
213 
214  const StlMap* associatedMap;
215 
216  private:
217 
218  ConstAbstractMapIterator(const ConstAbstractMapIterator&);
219  ConstAbstractMapIterator& operator= (const ConstAbstractMapIterator&);
220 
221  public:
222 
223  ConstAbstractMapIterator(const StlMap* parent) : position(0),
224  expectedModCount(parent->modCount),
225  futureEntry(parent->valueMap.begin()),
226  currentEntry(parent->valueMap.end()),
227  associatedMap(parent) {
228  }
229 
230  virtual ~ConstAbstractMapIterator() {}
231 
232  virtual bool checkHasNext() const {
233  if (futureEntry != this->associatedMap->valueMap.end()) {
234  return true;
235  }
236  return false;
237  }
238 
239  void checkConcurrentMod() const {
240  if (expectedModCount != this->associatedMap->modCount) {
242  __FILE__, __LINE__, "StlMap modified outside this iterator");
243  }
244  }
245 
246  void makeNext() {
247  checkConcurrentMod();
248 
249  if (!checkHasNext()) {
250  throw NoSuchElementException(__FILE__, __LINE__, "No next element");
251  }
252 
253  currentEntry = futureEntry;
254  futureEntry++;
255  }
256  };
257 
258  class ConstEntryIterator : public Iterator< MapEntry<K,V> >, public ConstAbstractMapIterator {
259  private:
260 
261  ConstEntryIterator(const ConstEntryIterator&);
262  ConstEntryIterator& operator= (const ConstEntryIterator&);
263 
264  public:
265 
266  ConstEntryIterator(const StlMap* parent) : ConstAbstractMapIterator(parent) {}
267 
268  virtual ~ConstEntryIterator() {}
269 
270  virtual bool hasNext() const {
271  return this->checkHasNext();
272  }
273 
274  virtual MapEntry<K, V> next() {
275  this->makeNext();
276  return MapEntry<K, V>(this->currentEntry->first, this->currentEntry->second);
277  }
278 
279  virtual void remove() {
281  __FILE__, __LINE__, "Cannot write to a const Iterator." );
282  }
283  };
284 
285  class ConstKeyIterator : public Iterator<K>, public ConstAbstractMapIterator {
286  private:
287 
288  ConstKeyIterator(const ConstKeyIterator&);
289  ConstKeyIterator& operator= (const ConstKeyIterator&);
290 
291  public:
292 
293  ConstKeyIterator(const StlMap* parent) : ConstAbstractMapIterator(parent) {
294  }
295 
296  virtual ~ConstKeyIterator() {}
297 
298  virtual bool hasNext() const {
299  return this->checkHasNext();
300  }
301 
302  virtual K next() {
303  this->makeNext();
304  return this->currentEntry->first;
305  }
306 
307  virtual void remove() {
309  __FILE__, __LINE__, "Cannot write to a const Iterator." );
310  }
311  };
312 
313  class ConstValueIterator : public Iterator<V>, public ConstAbstractMapIterator {
314  private:
315 
316  ConstValueIterator(const ConstValueIterator&);
317  ConstValueIterator& operator= (const ConstValueIterator&);
318 
319  public:
320 
321  ConstValueIterator(const StlMap* parent) : ConstAbstractMapIterator(parent) {}
322 
323  virtual ~ConstValueIterator() {}
324 
325  virtual bool hasNext() const {
326  return this->checkHasNext();
327  }
328 
329  virtual V next() {
330  this->makeNext();
331  return this->currentEntry->second;
332  }
333 
334  virtual void remove() {
336  __FILE__, __LINE__, "Cannot write to a const Iterator." );
337  }
338  };
339 
340  private:
341 
342  // Special Set implementation that is backed by this HashMap
343  class StlMapEntrySet : public AbstractSet< MapEntry<K, V> > {
344  private:
345 
346  StlMap* associatedMap;
347 
348  private:
349 
350  StlMapEntrySet(const StlMapEntrySet&);
351  StlMapEntrySet& operator= (const StlMapEntrySet&);
352 
353  public:
354 
355  StlMapEntrySet(StlMap* parent) : AbstractSet< MapEntry<K,V> >(), associatedMap(parent) {}
356 
357  virtual ~StlMapEntrySet() {}
358 
359  virtual int size() const {
360  return associatedMap->size();
361  }
362 
363  virtual void clear() {
364  associatedMap->clear();
365  }
366 
367  virtual bool remove(const MapEntry<K,V>& entry) {
368  if (this->associatedMap->containsKey(entry.getKey()) &&
369  this->associatedMap->get(entry.getKey()) == entry.getValue()) {
370  associatedMap->remove(entry.getKey());
371  return true;
372  }
373 
374  return false;
375  }
376 
377  virtual bool contains(const MapEntry<K,V>& entry) const {
378  if (this->associatedMap->containsKey(entry.getKey()) &&
379  this->associatedMap->get(entry.getKey()) == entry.getValue()) {
380  return true;
381  }
382  return false;
383  }
384 
385  virtual Iterator< MapEntry<K, V> >* iterator() {
386  return new EntryIterator(associatedMap);
387  }
388 
389  virtual Iterator< MapEntry<K, V> >* iterator() const {
390  return new ConstEntryIterator(associatedMap);
391  }
392  };
393 
394  // Special Set implementation that is backed by this HashMap
395  class ConstStlMapEntrySet : public AbstractSet< MapEntry<K, V> > {
396  private:
397 
398  const StlMap* associatedMap;
399 
400  private:
401 
402  ConstStlMapEntrySet(const ConstStlMapEntrySet&);
403  ConstStlMapEntrySet& operator= (const ConstStlMapEntrySet&);
404 
405  public:
406 
407  ConstStlMapEntrySet(const StlMap* parent) : AbstractSet< MapEntry<K,V> >(), associatedMap(parent) {
408  }
409 
410  virtual ~ConstStlMapEntrySet() {}
411 
412  virtual int size() const {
413  return associatedMap->size();
414  }
415 
416  virtual void clear() {
418  __FILE__, __LINE__, "Can't clear a const collection");
419  }
420 
421  virtual bool remove(const MapEntry<K,V>& entry DECAF_UNUSED) {
423  __FILE__, __LINE__, "Can't remove from const collection");
424  }
425 
426  virtual bool contains(const MapEntry<K,V>& entry) const {
427  if (this->associatedMap->containsKey(entry.getKey()) &&
428  this->associatedMap->get(entry.getKey()) == entry.getValue()) {
429  return true;
430  }
431  return false;
432  }
433 
434  virtual Iterator< MapEntry<K, V> >* iterator() {
436  __FILE__, __LINE__, "Can't return a non-const iterator for a const collection");
437  }
438 
439  virtual Iterator< MapEntry<K, V> >* iterator() const {
440  return new ConstEntryIterator(associatedMap);
441  }
442  };
443 
444  private:
445 
446  class StlMapKeySet : public AbstractSet<K> {
447  private:
448 
449  StlMap* associatedMap;
450 
451  private:
452 
453  StlMapKeySet(const StlMapKeySet&);
454  StlMapKeySet& operator= (const StlMapKeySet&);
455 
456  public:
457 
458  StlMapKeySet(StlMap* parent) : AbstractSet<K>(), associatedMap(parent) {}
459 
460  virtual ~StlMapKeySet() {}
461 
462  virtual bool contains(const K& key) const {
463  return this->associatedMap->containsKey(key);
464  }
465 
466  virtual int size() const {
467  return this->associatedMap->size();
468  }
469 
470  virtual void clear() {
471  this->associatedMap->clear();
472  }
473 
474  virtual bool remove(const K& key) {
475  if (this->associatedMap->containsKey(key)) {
476  associatedMap->remove(key);
477  return true;
478  }
479  return false;
480  }
481 
482  virtual Iterator<K>* iterator() {
483  return new KeyIterator(this->associatedMap);
484  }
485 
486  virtual Iterator<K>* iterator() const {
487  return new ConstKeyIterator(this->associatedMap);
488  }
489  };
490 
491  class ConstStlMapKeySet : public AbstractSet<K> {
492  private:
493 
494  const StlMap* associatedMap;
495 
496  private:
497 
498  ConstStlMapKeySet(const ConstStlMapKeySet&);
499  ConstStlMapKeySet& operator= (const ConstStlMapKeySet&);
500 
501  public:
502 
503  ConstStlMapKeySet(const StlMap* parent) : AbstractSet<K>(), associatedMap(parent) {}
504 
505  virtual ~ConstStlMapKeySet() {}
506 
507  virtual bool contains(const K& key) const {
508  return this->associatedMap->containsKey(key);
509  }
510 
511  virtual int size() const {
512  return this->associatedMap->size();
513  }
514 
515  virtual void clear() {
517  __FILE__, __LINE__, "Can't modify a const collection");
518  }
519 
520  virtual bool remove(const K& key DECAF_UNUSED) {
522  __FILE__, __LINE__, "Can't modify a const collection");
523  }
524 
525  virtual Iterator<K>* iterator() {
527  __FILE__, __LINE__, "Can't return a non-const iterator for a const collection");
528  }
529 
530  virtual Iterator<K>* iterator() const {
531  return new ConstKeyIterator(this->associatedMap);
532  }
533  };
534 
535  private:
536 
537  class StlMapValueCollection : public AbstractCollection<V> {
538  private:
539 
540  StlMap* associatedMap;
541 
542  private:
543 
544  StlMapValueCollection(const StlMapValueCollection&);
545  StlMapValueCollection& operator= (const StlMapValueCollection&);
546 
547  public:
548 
549  StlMapValueCollection(StlMap* parent) : AbstractCollection<V>(), associatedMap(parent) {}
550 
551  virtual ~StlMapValueCollection() {}
552 
553  virtual bool contains(const V& value) const {
554  return this->associatedMap->containsValue(value);
555  }
556 
557  virtual int size() const {
558  return this->associatedMap->size();
559  }
560 
561  virtual void clear() {
562  this->associatedMap->clear();
563  }
564 
565  virtual Iterator<V>* iterator() {
566  return new ValueIterator(this->associatedMap);
567  }
568 
569  virtual Iterator<V>* iterator() const {
570  return new ConstValueIterator(this->associatedMap);
571  }
572  };
573 
574  class ConstStlMapValueCollection : public AbstractCollection<V> {
575  private:
576 
577  const StlMap* associatedMap;
578 
579  private:
580 
581  ConstStlMapValueCollection(const ConstStlMapValueCollection&);
582  ConstStlMapValueCollection& operator= (const ConstStlMapValueCollection&);
583 
584  public:
585 
586  ConstStlMapValueCollection(const StlMap* parent) : AbstractCollection<V>(), associatedMap(parent) {}
587 
588  virtual ~ConstStlMapValueCollection() {}
589 
590  virtual bool contains(const V& value) const {
591  return this->associatedMap->containsValue(value);
592  }
593 
594  virtual int size() const {
595  return this->associatedMap->size();
596  }
597 
598  virtual void clear() {
600  __FILE__, __LINE__, "Can't modify a const collection");
601  }
602 
603  virtual Iterator<V>* iterator() {
605  __FILE__, __LINE__, "Can't return a non-const iterator for a const collection");
606  }
607 
608  virtual Iterator<V>* iterator() const {
609  return new ConstValueIterator(this->associatedMap);
610  }
611  };
612 
613  private:
614 
615  // Cached values that are only initialized once a request for them is made.
618  decaf::lang::Pointer<StlMapValueCollection> cachedValueCollection;
619 
620  // Cached values that are only initialized once a request for them is made.
621  mutable decaf::lang::Pointer<ConstStlMapEntrySet> cachedConstEntrySet;
622  mutable decaf::lang::Pointer<ConstStlMapKeySet> cachedConstKeySet;
623  mutable decaf::lang::Pointer<ConstStlMapValueCollection> cachedConstValueCollection;
624 
625  public:
626 
630  StlMap() : Map<K,V>(), valueMap(), mutex(), modCount(0),
631  cachedEntrySet(), cachedKeySet(), cachedValueCollection(),
632  cachedConstEntrySet(), cachedConstKeySet(), cachedConstValueCollection() {
633  }
634 
641  StlMap(const StlMap& source ) : Map<K,V>(), valueMap(), mutex(), modCount(0),
642  cachedEntrySet(), cachedKeySet(), cachedValueCollection(),
643  cachedConstEntrySet(), cachedConstKeySet(), cachedConstValueCollection() {
644  copy(source);
645  }
646 
653  StlMap(const Map<K,V>& source) : Map<K,V>(), valueMap(), mutex(), modCount(0),
654  cachedEntrySet(), cachedKeySet(), cachedValueCollection(),
655  cachedConstEntrySet(), cachedConstKeySet(), cachedConstValueCollection() {
656  copy(source);
657  }
658 
659  virtual ~StlMap() {}
660 
664  virtual bool equals(const StlMap& source) const {
665  return this->valueMap == source.valueMap;
666  }
667 
671  virtual bool equals(const Map<K,V>& source) const {
672  typename std::auto_ptr< Iterator<K> > iterator(this->keySet().iterator());
673  while (iterator->hasNext()) {
674  K key = iterator->next();
675  if (!this->containsKey(key)) {
676  return false;
677  }
678 
679  if (!(this->get(key) == source.get(key))) {
680  return false;
681  }
682  }
683 
684  return true;
685  }
686 
690  virtual void copy(const StlMap& source) {
691  this->valueMap.clear();
692  this->valueMap.insert( source.valueMap.begin(), source.valueMap.end() );
693  }
694 
698  virtual void copy(const Map<K, V>& source) {
699  this->clear();
700  this->putAll(source);
701  }
702 
706  virtual void clear() {
707  valueMap.clear();
708  }
709 
713  virtual bool containsKey(const K& key) const {
714  if (valueMap.empty()) {
715  return false;
716  }
717 
718  typename std::map<K, V, COMPARATOR>::const_iterator iter;
719  iter = valueMap.find(key);
720  return iter != valueMap.end();
721  }
722 
726  virtual bool containsValue(const V& value) const {
727  if (valueMap.empty()) {
728  return false;
729  }
730 
731  typename std::map<K, V, COMPARATOR>::const_iterator iter = valueMap.begin();
732  for (; iter != valueMap.end(); ++iter) {
733  if ((*iter).second == value) {
734  return true;
735  }
736  }
737 
738  return false;
739  }
740 
744  virtual bool isEmpty() const {
745  return valueMap.empty();
746  }
747 
751  virtual int size() const {
752  return (int)valueMap.size();
753  }
754 
758  virtual V& get(const K& key) {
759  typename std::map<K, V, COMPARATOR>::iterator iter;
760  iter = valueMap.find(key);
761  if (iter == valueMap.end()) {
762  throw NoSuchElementException(__FILE__, __LINE__, "Key does not exist in map");
763  }
764 
765  return iter->second;
766  }
767 
771  virtual const V& get(const K& key) const {
772  typename std::map<K, V, COMPARATOR>::const_iterator iter;
773  iter = valueMap.find(key);
774  if (iter == valueMap.end()) {
775  throw NoSuchElementException(__FILE__, __LINE__, "Key does not exist in map");
776  }
777 
778  return iter->second;
779  }
780 
784  virtual bool put(const K& key, const V& value) {
785  bool result = false;
786  if (this->containsKey(key)) {
787  result = true;
788  }
789  valueMap[key] = value;
790  modCount++;
791  return result;
792  }
793 
797  virtual bool put(const K& key, const V& value, V& oldValue) {
798  bool result = false;
799  if (this->containsKey(key)) {
800  result = true;
801  oldValue = valueMap[key];
802  }
803  valueMap[key] = value;
804  modCount++;
805  return result;
806  }
807 
811  virtual void putAll(const StlMap<K, V, COMPARATOR>& other) {
812  this->valueMap.insert(other.valueMap.begin(), other.valueMap.end());
813  this->modCount++;
814  }
815 
819  virtual void putAll(const Map<K, V>& other) {
820  typename std::auto_ptr< Iterator<K> > iterator(other.keySet().iterator());
821  while (iterator->hasNext()) {
822  K key = iterator->next();
823  this->put(key, other.get(key));
824  }
825  }
826 
830  virtual V remove(const K& key) {
831 
832  typename std::map<K, V, COMPARATOR>::iterator iter = valueMap.find(key);
833  if (iter == valueMap.end()) {
835  __FILE__, __LINE__, "Key is not present in this Map.");
836  }
837 
838  V result = iter->second;
839  valueMap.erase(iter);
840  modCount++;
841  return result;
842  }
843 
845  if (this->cachedEntrySet == NULL) {
846  this->cachedEntrySet.reset(new StlMapEntrySet(this));
847  }
848  return *(this->cachedEntrySet);
849  }
850  virtual const Set< MapEntry<K, V> >& entrySet() const {
851  if (this->cachedConstEntrySet == NULL) {
852  this->cachedConstEntrySet.reset(new ConstStlMapEntrySet(this));
853  }
854  return *(this->cachedConstEntrySet);
855  }
856 
857  virtual Set<K>& keySet() {
858  if (this->cachedKeySet == NULL) {
859  this->cachedKeySet.reset(new StlMapKeySet(this));
860  }
861  return *(this->cachedKeySet);
862  }
863 
864  virtual const Set<K>& keySet() const {
865  if (this->cachedConstKeySet == NULL) {
866  this->cachedConstKeySet.reset(new ConstStlMapKeySet(this));
867  }
868  return *(this->cachedConstKeySet);
869  }
870 
871  virtual Collection<V>& values() {
872  if (this->cachedValueCollection == NULL) {
873  this->cachedValueCollection.reset(new StlMapValueCollection(this));
874  }
875  return *(this->cachedValueCollection);
876  }
877 
878  virtual const Collection<V>& values() const {
879  if (this->cachedConstValueCollection == NULL) {
880  this->cachedConstValueCollection.reset(new ConstStlMapValueCollection(this));
881  }
882  return *(this->cachedConstValueCollection);
883  }
884 
885  public:
886 
887  virtual void lock() {
888  mutex.lock();
889  }
890 
891  virtual bool tryLock() {
892  return mutex.tryLock();
893  }
894 
895  virtual void unlock() {
896  mutex.unlock();
897  }
898 
899  virtual void wait() {
900  mutex.wait();
901  }
902 
903  virtual void wait( long long millisecs ) {
904  mutex.wait( millisecs );
905  }
906 
907  virtual void wait( long long millisecs, int nanos ) {
908  mutex.wait( millisecs, nanos );
909  }
910 
911  virtual void notify() {
912  mutex.notify();
913  }
914 
915  virtual void notifyAll() {
916  mutex.notifyAll();
917  }
918 
919  };
920 
921 }}
922 
923 #endif /*_DECAF_UTIL_STLMAP_H_*/
void reset(T *value=NULL)
Resets the Pointer to hold the new value.
Definition: Pointer.h:161
virtual const Set< K > & keySet() const
Definition: StlMap.h:864
Definition: ConcurrentModificationException.h:27
virtual bool tryLock()
Attempts to Lock the object, if the lock is already held by another thread than this method returns f...
virtual const Collection< V > & values() const
Definition: StlMap.h:878
virtual bool equals(const Map< K, V > &source) const
Compares the specified object with this map for equality.Returns true if the two maps represent the s...
Definition: StlMap.h:671
Mutex object that offers recursive support on all platforms as well as providing the ability to use t...
Definition: Mutex.h:39
virtual const Set< MapEntry< K, V > > & entrySet() const
Definition: StlMap.h:850
This class provides a skeletal implementation of the Collection interface, to minimize the effort req...
Definition: AbstractCollection.h:58
A collection that contains no duplicate elements.
Definition: Set.h:45
Map template that wraps around a std::map to provide a more user-friendly interface and to provide co...
Definition: StlMap.h:48
#define NULL
Definition: Config.h:33
virtual Collection< V > & values()
Returns a Collection view of the values contained in this map.
Definition: StlMap.h:871
virtual void unlock()
Unlocks the object.
Definition: StlMap.h:895
virtual void wait(long long millisecs, int nanos)
Waits on a signal from this object, which is generated by a call to Notify.
Definition: StlMap.h:907
virtual void unlock()
Unlocks the object.
virtual K & getKey()
Definition: MapEntry.h:57
virtual void wait()
Waits on a signal from this object, which is generated by a call to Notify.
Defines an object that can be used to iterate over the elements of a collection.
Definition: Iterator.h:34
virtual V & getValue()
Definition: MapEntry.h:69
virtual bool containsKey(const K &key) const
Returns true if this map contains a mapping for the specified key.More formally, returns true if and ...
Definition: StlMap.h:713
Definition: UnsupportedOperationException.h:32
virtual void copy(const StlMap &source)
Definition: StlMap.h:690
virtual void putAll(const StlMap< K, V, COMPARATOR > &other)
Definition: StlMap.h:811
virtual void wait(long long millisecs)
Waits on a signal from this object, which is generated by a call to Notify.
Definition: StlMap.h:903
virtual ~StlMap()
Definition: StlMap.h:659
virtual V & get(const K &key)=0
Gets the value mapped to the specified key in the Map.
virtual void notifyAll()
Signals the waiters on this object that it can now wake up and continue.
virtual decaf::util::Iterator< E > * iterator()=0
virtual void notify()
Signals a waiter on this object that it can now wake up and continue.
virtual bool containsValue(const V &value) const
Returns true if this map maps one or more keys to the specified value.More formally, returns true if and only if this map contains at least one mapping to a value v such that (value==v). This operation will probably require time linear in the map size for most implementations of the Map interface.The Value to look up in this Map.true if this map contains at least one mapping for the value, otherwise false.
Definition: StlMap.h:726
virtual void lock()
Locks the object.
An object that maps keys to values.
Definition: Map.h:88
virtual void clear()
Removes all of the mappings from this map (optional operation).The map will be empty after this call ...
Definition: StlMap.h:706
virtual void putAll(const Map< K, V > &other)
Copies all of the mappings from the specified map to this map (optional operation).The effect of this call is equivalent to that of calling put(k, v) on this map once for each mapping from key k to value v in the specified map. The behavior of this operation is undefined if the specified map is modified while the operation is in progress.A Map instance whose elements are to all be inserted in this Map.If the implementing class does not support the putAll operation.
Definition: StlMap.h:819
Definition: MapEntry.h:27
Definition: IllegalStateException.h:32
virtual Set< K > & keySet()
Returns a Set view of the keys contained in this map.
Definition: StlMap.h:857
virtual int size() const
The number of elements (key/value pairs) in this map.
Definition: StlMap.h:751
virtual Set< K > & keySet()=0
Returns a Set view of the keys contained in this map.
virtual Set< MapEntry< K, V > > & entrySet()
Returns a Set view of the mappings contained in this map.
Definition: StlMap.h:844
virtual bool put(const K &key, const V &value, V &oldValue)
Associates the specified value with the specified key in this map (optional operation).If the map previously contained a mapping for the key, the old value is replaced by the specified value. (A map m is said to contain a mapping for a key k if and only if m.containsKey(k) would return true.)This method accepts a reference to a value which will be assigned the previous value for the given key (if any). If there was no previous mapping for the given key the out value is not written to. A return of true indicates that a value was replaced by this put operation.The target key. The value to be set. (out) The value previously held in the mapping for this key. .true if the put operation replaced a value that was associated with an existing mapping to the given key or false otherwise.if this map is unmodifiable. if some property of the specified key or value prevents it from being stored in this map
Definition: StlMap.h:797
virtual bool tryLock()
Attempts to Lock the object, if the lock is already held by another thread than this method returns f...
Definition: StlMap.h:891
#define DECAF_UNUSED
Definition: Config.h:160
Definition: NoSuchElementException.h:31
StlMap()
Default constructor - does nothing.
Definition: StlMap.h:630
This class provides a skeletal implementation of the Set interface to minimize the effort required to...
Definition: AbstractSet.h:46
StlMap(const Map< K, V > &source)
Copy constructor - copies the content of the given map into this one.
Definition: StlMap.h:653
virtual bool equals(const StlMap &source) const
Definition: StlMap.h:664
virtual void wait()
Waits on a signal from this object, which is generated by a call to Notify.
Definition: StlMap.h:899
virtual void copy(const Map< K, V > &source)
Copies the content of the source map into this map.Erases all existing mappings in this map...
Definition: StlMap.h:698
virtual bool isEmpty() const
if the Map contains any element or not, TRUE or FALSE
Definition: StlMap.h:744
virtual void notify()
Signals a waiter on this object that it can now wake up and continue.
Definition: StlMap.h:911
StlMap(const StlMap &source)
Copy constructor - copies the content of the given map into this one.
Definition: StlMap.h:641
virtual bool put(const K &key, const V &value)
Associates the specified value with the specified key in this map (optional operation).If the map previously contained a mapping for the key, the old value is replaced by the specified value. (A map m is said to contain a mapping for a key k if and only if m.containsKey(k) would return true.)The target key. The value to be set.true if the put operation replaced a value that was associated with an existing mapping to the given key or false otherwise.if this map is unmodifiable. if some property of the specified key or value prevents it from being stored in this map
Definition: StlMap.h:784
virtual void lock()
Locks the object.
Definition: StlMap.h:887
virtual void notifyAll()
Signals the waiters on this object that it can now wake up and continue.
Definition: StlMap.h:915