activemq-cpp-3.8.2
LinkedHashMap.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_LINKEDHASHMAP_H_
19 #define _DECAF_UTIL_LINKEDHASHMAP_H_
20 
21 #include <decaf/util/Config.h>
22 
23 #include <decaf/util/HashMap.h>
24 
25 namespace decaf {
26 namespace util {
27 
110  template<typename K, typename V, typename HASHCODE = HashCode<K> >
111  class LinkedHashMap : public HashMap<K, V, HASHCODE> {
112  private:
113 
114  class LinkedHashMapEntry : public HashMap<K, V, HASHCODE>::HashMapEntry {
115  private:
116 
117  LinkedHashMapEntry(const LinkedHashMapEntry&);
118  LinkedHashMapEntry& operator= (const LinkedHashMapEntry&);
119 
120  public:
121 
122  LinkedHashMapEntry* chainForward;
123  LinkedHashMapEntry* chainBackward;
124 
125  public:
126 
127  LinkedHashMapEntry(const K& key, const V& value, int hash) :
128  HashMap<K, V, HASHCODE>::HashMapEntry(key, value, hash), chainForward(), chainBackward() {
129  }
130 
131  LinkedHashMapEntry(const K& key, const V& value) :
132  HashMap<K, V, HASHCODE>::HashMapEntry(key, value), chainForward(), chainBackward() {
133  }
134  };
135 
136  private:
137 
138  bool accessOrder;
139  mutable LinkedHashMapEntry* head;
140  mutable LinkedHashMapEntry* tail;
141 
142  private:
143 
144  class AbstractMapIterator {
145  protected:
146 
147  int expectedModCount;
148  LinkedHashMapEntry* futureEntry;
149  LinkedHashMapEntry* currentEntry;
150  LinkedHashMap* associatedMap;
151 
152  private:
153 
154  AbstractMapIterator(const AbstractMapIterator&);
155  AbstractMapIterator& operator= (const AbstractMapIterator&);
156 
157  public:
158 
159  AbstractMapIterator(LinkedHashMap* parent) : expectedModCount(parent->modCount),
160  futureEntry(parent->head),
161  currentEntry(NULL),
162  associatedMap(parent) {
163  }
164 
165  virtual ~AbstractMapIterator() {}
166 
167  void checkConcurrentMod() const {
168  if (expectedModCount != associatedMap->modCount) {
170  __FILE__, __LINE__, "LinkedHashMap modified outside this iterator");
171  }
172  }
173 
174  virtual bool checkHasNext() const {
175  return (futureEntry != NULL);
176  }
177 
178  void makeNext() {
179  checkConcurrentMod();
180  if (!checkHasNext()) {
182  __FILE__, __LINE__, "No next element");
183  }
184  currentEntry = futureEntry;
185  futureEntry = futureEntry->chainForward;
186  }
187 
188  virtual void doRemove() {
189  checkConcurrentMod();
190  if (currentEntry == NULL) {
192  __FILE__, __LINE__, "Remove called before call to next()");
193  }
194 
195  LinkedHashMapEntry* entry = currentEntry;
196  LinkedHashMapEntry* prev = entry->chainBackward;
197  LinkedHashMapEntry* next = entry->chainForward;
198  LinkedHashMap* map = associatedMap;
199 
200  // currentEntry gets deleted here.
201  associatedMap->removeEntry(currentEntry);
202  currentEntry = NULL;
203 
204  if (prev != NULL) {
205  prev->chainForward = next;
206  if (next != NULL) {
207  next->chainBackward = prev;
208  } else {
209  map->tail = prev;
210  }
211  } else {
212  map->head = next;
213  if (next != NULL) {
214  next->chainBackward = NULL;
215  } else {
216  map->tail = NULL;
217  }
218  }
219  expectedModCount++;
220  }
221 
222  };
223 
224  class EntryIterator : public Iterator< MapEntry<K,V> >, public AbstractMapIterator {
225  private:
226 
227  EntryIterator(const EntryIterator&);
228  EntryIterator& operator= (const EntryIterator&);
229 
230  public:
231 
232  EntryIterator(LinkedHashMap* parent) : AbstractMapIterator(parent) {
233  }
234 
235  virtual ~EntryIterator() {}
236 
237  virtual bool hasNext() const {
238  return this->checkHasNext();
239  }
240 
241  virtual MapEntry<K, V> next() {
242  this->makeNext();
243  return *(this->currentEntry);
244  }
245 
246  virtual void remove() {
247  this->doRemove();
248  }
249  };
250 
251  class KeyIterator : public Iterator<K>, public AbstractMapIterator {
252  private:
253 
254  KeyIterator(const KeyIterator&);
255  KeyIterator& operator= (const KeyIterator&);
256 
257  public:
258 
259  KeyIterator(LinkedHashMap* parent) : AbstractMapIterator(parent) {
260  }
261 
262  virtual ~KeyIterator() {}
263 
264  virtual bool hasNext() const {
265  return this->checkHasNext();
266  }
267 
268  virtual K next() {
269  this->makeNext();
270  return this->currentEntry->getKey();
271  }
272 
273  virtual void remove() {
274  this->doRemove();
275  }
276  };
277 
278  class ValueIterator : public Iterator<V>, public AbstractMapIterator {
279  private:
280 
281  ValueIterator(const ValueIterator&);
282  ValueIterator& operator= (const ValueIterator&);
283 
284  public:
285 
286  ValueIterator(LinkedHashMap* parent) : AbstractMapIterator(parent) {
287  }
288 
289  virtual ~ValueIterator() {}
290 
291  virtual bool hasNext() const {
292  return this->checkHasNext();
293  }
294 
295  virtual V next() {
296  this->makeNext();
297  return this->currentEntry->getValue();
298  }
299 
300  virtual void remove() {
301  this->doRemove();
302  }
303  };
304 
305  private:
306 
307  class ConstAbstractMapIterator {
308  protected:
309 
310  int expectedModCount;
311  const LinkedHashMapEntry* futureEntry;
312  const LinkedHashMapEntry* currentEntry;
313  const LinkedHashMap* associatedMap;
314 
315  private:
316 
317  ConstAbstractMapIterator(const ConstAbstractMapIterator&);
318  ConstAbstractMapIterator& operator= (const ConstAbstractMapIterator&);
319 
320  public:
321 
322  ConstAbstractMapIterator(const LinkedHashMap* parent) : expectedModCount(parent->modCount),
323  futureEntry(parent->head),
324  currentEntry(NULL),
325  associatedMap(parent) {
326  }
327 
328  virtual ~ConstAbstractMapIterator() {}
329 
330  virtual bool checkHasNext() const {
331  return (futureEntry != NULL);
332  }
333 
334  void checkConcurrentMod() const {
335  if (expectedModCount != associatedMap->modCount) {
337  __FILE__, __LINE__, "LinkedHashMap modified outside this iterator");
338  }
339  }
340 
341  void makeNext() {
342  checkConcurrentMod();
343  if (!checkHasNext()) {
345  __FILE__, __LINE__, "No next element");
346  }
347  currentEntry = futureEntry;
348  futureEntry = futureEntry->chainForward;
349  }
350  };
351 
352  class ConstEntryIterator : public Iterator< MapEntry<K,V> >, public ConstAbstractMapIterator {
353  private:
354 
355  ConstEntryIterator(const ConstEntryIterator&);
356  ConstEntryIterator& operator= (const ConstEntryIterator&);
357 
358  public:
359 
360  ConstEntryIterator(const LinkedHashMap* parent) : ConstAbstractMapIterator(parent) {
361  }
362 
363  virtual ~ConstEntryIterator() {}
364 
365  virtual bool hasNext() const {
366  return this->checkHasNext();
367  }
368 
369  virtual MapEntry<K, V> next() {
370  this->makeNext();
371  return *(this->currentEntry);
372  }
373 
374  virtual void remove() {
376  __FILE__, __LINE__, "Cannot write to a const Iterator." );
377  }
378  };
379 
380  class ConstKeyIterator : public Iterator<K>, public ConstAbstractMapIterator {
381  private:
382 
383  ConstKeyIterator(const ConstKeyIterator&);
384  ConstKeyIterator& operator= (const ConstKeyIterator&);
385 
386  public:
387 
388  ConstKeyIterator(const LinkedHashMap* parent) : ConstAbstractMapIterator(parent) {
389  }
390 
391  virtual ~ConstKeyIterator() {}
392 
393  virtual bool hasNext() const {
394  return this->checkHasNext();
395  }
396 
397  virtual K next() {
398  this->makeNext();
399  return this->currentEntry->getKey();
400  }
401 
402  virtual void remove() {
404  __FILE__, __LINE__, "Cannot write to a const Iterator." );
405  }
406  };
407 
408  class ConstValueIterator : public Iterator<V>, public ConstAbstractMapIterator {
409  private:
410 
411  ConstValueIterator(const ConstValueIterator&);
412  ConstValueIterator& operator= (const ConstValueIterator&);
413 
414  public:
415 
416  ConstValueIterator(const LinkedHashMap* parent) : ConstAbstractMapIterator(parent) {
417  }
418 
419  virtual ~ConstValueIterator() {}
420 
421  virtual bool hasNext() const {
422  return this->checkHasNext();
423  }
424 
425  virtual V next() {
426  this->makeNext();
427  return this->currentEntry->getValue();
428  }
429 
430  virtual void remove() {
432  __FILE__, __LINE__, "Cannot write to a const Iterator." );
433  }
434  };
435 
436  private:
437 
438  // Special Set implementation that is backed by this HashMap
439  class LinkedHashMapEntrySet : public HashMap<K, V, HASHCODE>::HashMapEntrySet {
440  private:
441 
442  LinkedHashMap* associatedMap;
443 
444  private:
445 
446  LinkedHashMapEntrySet(const LinkedHashMapEntrySet&);
447  LinkedHashMapEntrySet& operator= (const LinkedHashMapEntrySet&);
448 
449  public:
450 
451  LinkedHashMapEntrySet(LinkedHashMap* parent) :
452  HashMap<K, V, HASHCODE>::HashMapEntrySet(parent), associatedMap(parent) {
453  }
454 
455  virtual ~LinkedHashMapEntrySet() {}
456 
457  virtual Iterator< MapEntry<K, V> >* iterator() {
458  return new EntryIterator(associatedMap);
459  }
460 
461  virtual Iterator< MapEntry<K, V> >* iterator() const {
462  return new ConstEntryIterator(associatedMap);
463  }
464  };
465 
466  // Special Set implementation that is backed by this HashMap
467  class ConstLinkedHashMapEntrySet : public HashMap<K, V, HASHCODE>::ConstHashMapEntrySet {
468  private:
469 
470  const LinkedHashMap* associatedMap;
471 
472  private:
473 
474  ConstLinkedHashMapEntrySet(const ConstLinkedHashMapEntrySet&);
475  ConstLinkedHashMapEntrySet& operator= (const ConstLinkedHashMapEntrySet&);
476 
477  public:
478 
479  ConstLinkedHashMapEntrySet(const LinkedHashMap* parent) :
480  HashMap<K, V, HASHCODE>::ConstHashMapEntrySet(parent), associatedMap(parent) {
481  }
482 
483  virtual ~ConstLinkedHashMapEntrySet() {}
484 
485  virtual Iterator< MapEntry<K, V> >* iterator() {
487  __FILE__, __LINE__, "Can't return a non-const iterator for a const collection");
488  }
489 
490  virtual Iterator< MapEntry<K, V> >* iterator() const {
491  return new ConstEntryIterator(associatedMap);
492  }
493  };
494 
495  private:
496 
497  class LinkedHashMapKeySet : public HashMap<K, V, HASHCODE>::HashMapKeySet {
498  private:
499 
500  LinkedHashMap* associatedMap;
501 
502  private:
503 
504  LinkedHashMapKeySet(const LinkedHashMapKeySet&);
505  LinkedHashMapKeySet& operator= (const LinkedHashMapKeySet&);
506 
507  public:
508 
509  LinkedHashMapKeySet(LinkedHashMap* parent) :
510  HashMap<K, V, HASHCODE>::HashMapKeySet(parent), associatedMap(parent) {
511  }
512 
513  virtual ~LinkedHashMapKeySet() {}
514 
515  virtual Iterator<K>* iterator() {
516  return new KeyIterator(this->associatedMap);
517  }
518 
519  virtual Iterator<K>* iterator() const {
520  return new ConstKeyIterator(this->associatedMap);
521  }
522  };
523 
524  class ConstLinkedHashMapKeySet : public HashMap<K, V, HASHCODE>::ConstHashMapKeySet {
525  private:
526 
527  const LinkedHashMap* associatedMap;
528 
529  private:
530 
531  ConstLinkedHashMapKeySet(const ConstLinkedHashMapKeySet&);
532  ConstLinkedHashMapKeySet& operator= (const ConstLinkedHashMapKeySet&);
533 
534  public:
535 
536  ConstLinkedHashMapKeySet(const LinkedHashMap* parent) :
537  HashMap<K, V, HASHCODE>::ConstHashMapKeySet(parent), associatedMap(parent) {
538  }
539 
540  virtual ~ConstLinkedHashMapKeySet() {}
541 
542  virtual Iterator<K>* iterator() const {
543  return new ConstKeyIterator(this->associatedMap);
544  }
545  };
546 
547  private:
548 
549  class LinkedHashMapValueCollection : public HashMap<K, V, HASHCODE>::HashMapValueCollection {
550  private:
551 
552  LinkedHashMap* associatedMap;
553 
554  private:
555 
556  LinkedHashMapValueCollection(const LinkedHashMapValueCollection&);
557  LinkedHashMapValueCollection& operator= (const LinkedHashMapValueCollection&);
558 
559  public:
560 
561  LinkedHashMapValueCollection(LinkedHashMap* parent) :
562  HashMap<K, V, HASHCODE>::HashMapValueCollection(parent), associatedMap(parent) {
563  }
564 
565  virtual ~LinkedHashMapValueCollection() {}
566 
567  virtual Iterator<V>* iterator() {
568  return new ValueIterator(this->associatedMap);
569  }
570 
571  virtual Iterator<V>* iterator() const {
572  return new ConstValueIterator(this->associatedMap);
573  }
574  };
575 
576  class ConstLinkedHashMapValueCollection : public HashMap<K, V, HASHCODE>::ConstHashMapValueCollection {
577  private:
578 
579  const LinkedHashMap* associatedMap;
580 
581  private:
582 
583  ConstLinkedHashMapValueCollection(const ConstLinkedHashMapValueCollection&);
584  ConstLinkedHashMapValueCollection& operator= (const ConstLinkedHashMapValueCollection&);
585 
586  public:
587 
588  ConstLinkedHashMapValueCollection(const LinkedHashMap* parent) :
589  HashMap<K, V, HASHCODE>::ConstHashMapValueCollection(parent), associatedMap(parent) {
590  }
591 
592  virtual ~ConstLinkedHashMapValueCollection() {}
593 
594  virtual Iterator<V>* iterator() const {
595  return new ConstValueIterator(this->associatedMap);
596  }
597  };
598 
599  public:
600 
605  LinkedHashMap() : HashMap<K, V, HASHCODE>(), accessOrder(false), head(), tail() {
606  }
607 
616  LinkedHashMap(int capacity) : HashMap<K, V, HASHCODE>(capacity), accessOrder(false), head(), tail() {
617  }
618 
631  LinkedHashMap(int capacity, float load) :
632  HashMap<K, V, HASHCODE>(capacity, load), accessOrder(false), head(), tail() {
633 
634  }
635 
652  LinkedHashMap(int capacity, float load, bool order) :
653  HashMap<K, V, HASHCODE>(capacity, load), accessOrder(order), head(), tail() {
654  }
655 
663  LinkedHashMap(const HashMap<K,V>& map) : HashMap<K, V, HASHCODE>(map), accessOrder(false), head(), tail() {
664  }
665 
666  virtual ~LinkedHashMap() {}
667 
668  protected:
669 
681  virtual bool removeEldestEntry(const MapEntry<K, V>& eldest DECAF_UNUSED) {
682  return false;
683  }
684 
694  virtual void onEviction(const MapEntry<K, V>& eldest DECAF_UNUSED) {}
695 
696  public:
697 
698  virtual bool containsValue(const V& value) const {
699  LinkedHashMapEntry* entry = head;
700  while (entry != NULL) {
701  if (value == entry->getValue()) {
702  return true;
703  }
704  entry = entry->chainForward;
705  }
706  return false;
707  }
708 
709  virtual void clear() {
711  this->head = NULL;
712  this->tail = NULL;
713  }
714 
715  virtual bool put(const K& key, const V& value) {
716  bool result = this->putImpl(key, value);
717 
718  if (this->removeEldestEntry(*head)) {
719  this->onEviction(*head);
720  this->remove(head->getKey());
721  }
722 
723  return result;
724  }
725 
726  virtual bool put(const K& key, const V& value, V& oldValue) {
727  bool result = this->putImpl(key, value, oldValue);
728 
729  if (this->removeEldestEntry(*head)) {
730  this->onEviction(*head);
731  this->remove(head->getKey());
732  }
733 
734  return result;
735  }
736 
737  virtual V remove(const K& key) {
738 
739  LinkedHashMapEntry* toRemove = (LinkedHashMapEntry*) this->removeEntry(key);
740  if (toRemove != NULL) {
741  LinkedHashMapEntry* prev = toRemove->chainBackward;
742  LinkedHashMapEntry* next = toRemove->chainForward;
743  if (prev != NULL) {
744  prev->chainForward = next;
745  } else {
746  head = next;
747  }
748  if (next != NULL) {
749  next->chainBackward = prev;
750  } else {
751  tail = prev;
752  }
753 
754  V oldValue = toRemove->getValue();
755  delete toRemove;
756  return oldValue;
757  }
758 
760  __FILE__, __LINE__, "Specified key not present in the Map.");
761  }
762 
764  if (this->cachedEntrySet == NULL) {
765  this->cachedEntrySet.reset(new LinkedHashMapEntrySet(this));
766  }
767  return *(this->cachedEntrySet);
768  }
769 
770  virtual const Set< MapEntry<K,V> >& entrySet() const {
771  if (this->cachedConstEntrySet == NULL) {
772  this->cachedConstEntrySet.reset(new ConstLinkedHashMapEntrySet(this));
773  }
774  return *(this->cachedConstEntrySet);
775  }
776 
777  virtual Set<K>& keySet() {
778  if (this->cachedKeySet == NULL) {
779  this->cachedKeySet.reset(new LinkedHashMapKeySet(this));
780  }
781  return *(this->cachedKeySet);
782  }
783 
784  virtual const Set<K>& keySet() const {
785  if (this->cachedConstKeySet == NULL) {
786  this->cachedConstKeySet.reset(new ConstLinkedHashMapKeySet(this));
787  }
788  return *(this->cachedConstKeySet);
789  }
790 
791  virtual Collection<V>& values() {
792  if (this->cachedValueCollection == NULL) {
793  this->cachedValueCollection.reset(new LinkedHashMapValueCollection(this));
794  }
795  return *(this->cachedValueCollection);
796  }
797 
798  virtual const Collection<V>& values() const {
799  if (this->cachedConstValueCollection == NULL) {
800  this->cachedConstValueCollection.reset(new ConstLinkedHashMapValueCollection(this));
801  }
802  return *(this->cachedConstValueCollection);
803  }
804 
805  virtual std::string toString() const {
806  return "LinkedHashMap";
807  }
808 
809  protected:
810 
811  virtual LinkedHashMapEntry* getEntry(const K& key) const {
812  LinkedHashMapEntry* result = NULL;
813 
814  int hash = this->hashFunc(key);
815  int index = hash & (this->elementData.length() - 1);
816  result = (LinkedHashMapEntry*) this->findKeyEntry(key, index, hash);
817 
818  if (result != NULL && accessOrder && tail != result) {
819  LinkedHashMapEntry* prev = result->chainBackward;
820  LinkedHashMapEntry* next = result->chainForward;
821  next->chainBackward = prev;
822  if (prev != NULL) {
823  prev->chainForward = next;
824  } else {
825  head = next;
826  }
827  result->chainForward = NULL;
828  result->chainBackward = tail;
829  tail->chainForward = result;
830  tail = result;
831  }
832 
833  return result;
834  }
835 
836  virtual typename HashMap<K, V, HASHCODE>::HashMapEntry* createEntry(const K& key, int index, const V& value) {
837  LinkedHashMapEntry* entry = new LinkedHashMapEntry(key, value);
838  entry->next = this->elementData[index];
839  this->elementData[index] = entry;
840  linkEntry(entry);
841  return entry;
842  }
843 
844  virtual typename HashMap<K, V, HASHCODE>::HashMapEntry* createHashedEntry(const K& key, int index, int hash) {
845  LinkedHashMapEntry* entry = new LinkedHashMapEntry(key, V(), hash);
846  entry->next = this->elementData[index];
847  this->elementData[index] = entry;
848  linkEntry(entry);
849  return entry;
850  }
851 
852  void linkEntry(LinkedHashMapEntry* entry) {
853  if (tail == entry) {
854  return;
855  }
856 
857  if (head == NULL) {
858  // Check if the map is empty
859  head = tail = entry;
860  return;
861  }
862 
863  // we need to link the new entry into either the head or tail
864  // of the chain depending on if the LinkedHashMap is accessOrder or not
865  LinkedHashMapEntry* prev = entry->chainBackward;
866  LinkedHashMapEntry* next = entry->chainForward;
867  if (prev == NULL) {
868  if (next != NULL) {
869  // The entry must be the head but not the tail
870  if (accessOrder) {
871  head = next;
872  next->chainBackward = NULL;
873  entry->chainBackward = tail;
874  entry->chainForward = NULL;
875  tail->chainForward = entry;
876  tail = entry;
877  }
878  } else {
879  // This is a new entry
880  entry->chainBackward = tail;
881  entry->chainForward = NULL;
882  tail->chainForward = entry;
883  tail = entry;
884  }
885  return;
886  }
887 
888  if (next == NULL) {
889  // The entry must be the tail so we can't get here
890  return;
891  }
892 
893  // The entry is neither the head nor tail
894  if (accessOrder) {
895  prev->chainForward = next;
896  next->chainBackward = prev;
897  entry->chainForward = NULL;
898  entry->chainBackward = tail;
899  tail->chainForward = entry;
900  tail = entry;
901  }
902  }
903 
904  virtual bool putImpl(const K& key, const V& value) {
905  V oldValue;
906  return putImpl(key, value, oldValue);
907  }
908 
909  virtual bool putImpl(const K& key, const V& value, V& oldValue) {
910 
911  LinkedHashMapEntry* entry;
912  if (this->elementCount == 0) {
913  head = tail = NULL;
914  }
915 
916  bool replaced = true;
917  int hash = this->hashFunc(key);
918  int index = hash & (this->elementData.length() - 1);
919 
920  entry = (LinkedHashMapEntry*) this->findKeyEntry(key, index, hash);
921  if (entry == NULL) {
922  this->modCount++;
923  if (++this->elementCount > this->threshold) {
924  this->rehash();
925  index = hash & (this->elementData.length() - 1);
926  }
927  entry = (LinkedHashMapEntry*) this->createHashedEntry(key, index, hash);
928  replaced = false;
929  } else {
930  this->linkEntry(entry);
931  oldValue = entry->getValue();
932  }
933 
934  entry->setValue(value);
935  return replaced;
936  }
937 
938  };
939 
940 }}
941 
942 #endif /* _DECAF_UTIL_LINKEDHASHMAP_H_ */
void removeEntry(HashMapEntry *entry)
Definition: HashMap.h:1203
virtual bool removeEldestEntry(const MapEntry< K, V > &eldest DECAF_UNUSED)
This method is queried from the put and putAll methods to check if the eldest member of the map shoul...
Definition: LinkedHashMap.h:681
virtual const Set< K > & keySet() const
Definition: LinkedHashMap.h:784
Definition: ConcurrentModificationException.h:27
decaf::lang::Pointer< HashMapKeySet > cachedKeySet
Definition: HashMap.h:769
decaf::lang::Pointer< HashMapEntrySet > cachedEntrySet
Definition: HashMap.h:768
virtual const Set< MapEntry< K, V > > & entrySet() const
Definition: LinkedHashMap.h:770
LinkedHashMap(int capacity)
Constructs a new LinkedHashMap instance with the specified capacity.
Definition: LinkedHashMap.h:616
int modCount
Definition: HashMap.h:755
decaf::lang::Pointer< ConstHashMapValueCollection > cachedConstValueCollection
Definition: HashMap.h:775
A collection that contains no duplicate elements.
Definition: Set.h:45
virtual bool putImpl(const K &key, const V &value)
Definition: LinkedHashMap.h:904
Definition: HashMap.h:562
Definition: HashMap.h:511
LinkedHashMap()
Constructs an empty insertion-ordered LinkedHashMap instance with the default initial capacity (16) a...
Definition: LinkedHashMap.h:605
virtual LinkedHashMapEntry * getEntry(const K &key) const
Definition: LinkedHashMap.h:811
LinkedHashMap(int capacity, float load)
Constructs a new.
Definition: LinkedHashMap.h:631
virtual void onEviction(const MapEntry< K, V > &eldest DECAF_UNUSED)
This method is called when the removeEldestEntry has returned true and a MapEntry is about to be remo...
Definition: LinkedHashMap.h:694
#define NULL
Definition: Config.h:33
virtual std::string toString() const
Definition: LinkedHashMap.h:805
LinkedHashMap(const HashMap< K, V > &map)
Constructs a new LinkedHashMap instance containing the mappings from the specified map...
Definition: LinkedHashMap.h:663
int elementCount
Definition: HashMap.h:744
virtual void clear()
Removes all of the mappings from this map (optional operation).
Definition: HashMap.h:923
virtual const Collection< V > & values() const
Definition: LinkedHashMap.h:798
Defines an object that can be used to iterate over the elements of a collection.
Definition: Iterator.h:34
Definition: UnsupportedOperationException.h:32
virtual HashMap< K, V, HASHCODE >::HashMapEntry * createHashedEntry(const K &key, int index, int hash)
Definition: LinkedHashMap.h:844
void linkEntry(LinkedHashMapEntry *entry)
Definition: LinkedHashMap.h:852
LinkedHashMap(int capacity, float load, bool order)
Constructs a new.
Definition: LinkedHashMap.h:652
virtual bool put(const K &key, const V &value)
Associates the specified value with the specified key in this map (optional operation).
Definition: LinkedHashMap.h:715
decaf::lang::Pointer< ConstHashMapEntrySet > cachedConstEntrySet
Definition: HashMap.h:773
Hashed and linked list implementation of the Map interface, with predictable iteration order...
Definition: LinkedHashMap.h:111
decaf::lang::ArrayPointer< HashMapEntry * > elementData
Definition: HashMap.h:749
decaf::lang::Pointer< ConstHashMapKeySet > cachedConstKeySet
Definition: HashMap.h:774
virtual void clear()
Removes all of the mappings from this map (optional operation).
Definition: LinkedHashMap.h:709
Definition: MapEntry.h:27
Definition: IllegalStateException.h:32
Hash table based implementation of the Map interface.
Definition: HashMap.h:95
Definition: HashMap.h:98
HashMapEntry * findKeyEntry(const K &key, int index, int keyHash) const
Definition: HashMap.h:1171
Definition: HashMap.h:458
#define DECAF_UNUSED
Definition: Config.h:160
Definition: NoSuchElementException.h:31
virtual HashMap< K, V, HASHCODE >::HashMapEntry * createEntry(const K &key, int index, const V &value)
Definition: LinkedHashMap.h:836
virtual Collection< V > & values()
Returns a Collection view of the values contained in this map.
Definition: LinkedHashMap.h:791
virtual ~LinkedHashMap()
Definition: LinkedHashMap.h:666
HASHCODE hashFunc
The Hash Code generator for this map&#39;s keys.
Definition: HashMap.h:739
virtual bool containsValue(const V &value) const
Returns true if this map maps one or more keys to the specified value.
Definition: LinkedHashMap.h:698
virtual bool put(const K &key, const V &value, V &oldValue)
Associates the specified value with the specified key in this map (optional operation).
Definition: LinkedHashMap.h:726
int threshold
Definition: HashMap.h:765
virtual Set< K > & keySet()
Returns a Set view of the keys contained in this map.
Definition: LinkedHashMap.h:777
void rehash()
Definition: HashMap.h:1198
virtual bool putImpl(const K &key, const V &value, V &oldValue)
Definition: LinkedHashMap.h:909
decaf::lang::Pointer< HashMapValueCollection > cachedValueCollection
Definition: HashMap.h:770
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: AprPool.h:25
virtual Set< MapEntry< K, V > > & entrySet()
Returns a Set view of the mappings contained in this map.
Definition: LinkedHashMap.h:763