activemq-cpp-3.9.5
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
25namespace decaf {
26namespace 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 using HashMap<K, V, HASHCODE>::ConstHashMapKeySet::iterator;
543
544 virtual Iterator<K>* iterator() const {
545 return new ConstKeyIterator(this->associatedMap);
546 }
547 };
548
549 private:
550
551 class LinkedHashMapValueCollection : public HashMap<K, V, HASHCODE>::HashMapValueCollection {
552 private:
553
554 LinkedHashMap* associatedMap;
555
556 private:
557
558 LinkedHashMapValueCollection(const LinkedHashMapValueCollection&);
559 LinkedHashMapValueCollection& operator= (const LinkedHashMapValueCollection&);
560
561 public:
562
563 LinkedHashMapValueCollection(LinkedHashMap* parent) :
564 HashMap<K, V, HASHCODE>::HashMapValueCollection(parent), associatedMap(parent) {
565 }
566
567 virtual ~LinkedHashMapValueCollection() {}
568
569 virtual Iterator<V>* iterator() {
570 return new ValueIterator(this->associatedMap);
571 }
572
573 virtual Iterator<V>* iterator() const {
574 return new ConstValueIterator(this->associatedMap);
575 }
576 };
577
578 class ConstLinkedHashMapValueCollection : public HashMap<K, V, HASHCODE>::ConstHashMapValueCollection {
579 private:
580
581 const LinkedHashMap* associatedMap;
582
583 private:
584
585 ConstLinkedHashMapValueCollection(const ConstLinkedHashMapValueCollection&);
586 ConstLinkedHashMapValueCollection& operator= (const ConstLinkedHashMapValueCollection&);
587
588 public:
589
590 ConstLinkedHashMapValueCollection(const LinkedHashMap* parent) :
591 HashMap<K, V, HASHCODE>::ConstHashMapValueCollection(parent), associatedMap(parent) {
592 }
593
594 virtual ~ConstLinkedHashMapValueCollection() {}
595
596 virtual Iterator<V>* iterator() const {
597 return new ConstValueIterator(this->associatedMap);
598 }
599
600 using HashMap<K, V, HASHCODE>::ConstHashMapValueCollection::iterator;
601 };
602
603 public:
604
609 LinkedHashMap() : HashMap<K, V, HASHCODE>(), accessOrder(false), head(), tail() {
610 }
611
620 LinkedHashMap(int capacity) : HashMap<K, V, HASHCODE>(capacity), accessOrder(false), head(), tail() {
621 }
622
635 LinkedHashMap(int capacity, float load) :
636 HashMap<K, V, HASHCODE>(capacity, load), accessOrder(false), head(), tail() {
637
638 }
639
656 LinkedHashMap(int capacity, float load, bool order) :
657 HashMap<K, V, HASHCODE>(capacity, load), accessOrder(order), head(), tail() {
658 }
659
667 LinkedHashMap(const HashMap<K,V>& map) : HashMap<K, V, HASHCODE>(map), accessOrder(false), head(), tail() {
668 }
669
670 virtual ~LinkedHashMap() {}
671
672 protected:
673
685 virtual bool removeEldestEntry(const MapEntry<K, V>& eldest DECAF_UNUSED) {
686 return false;
687 }
688
698 virtual void onEviction(const MapEntry<K, V>& eldest DECAF_UNUSED) {}
699
700 public:
701
702 virtual bool containsValue(const V& value) const {
703 LinkedHashMapEntry* entry = head;
704 while (entry != NULL) {
705 if (value == entry->getValue()) {
706 return true;
707 }
708 entry = entry->chainForward;
709 }
710 return false;
711 }
712
713 virtual void clear() {
715 this->head = NULL;
716 this->tail = NULL;
717 }
718
719 virtual bool put(const K& key, const V& value) {
720 bool result = this->putImpl(key, value);
721
722 if (this->removeEldestEntry(*head)) {
723 this->onEviction(*head);
724 this->remove(head->getKey());
725 }
726
727 return result;
728 }
729
730 virtual bool put(const K& key, const V& value, V& oldValue) {
731 bool result = this->putImpl(key, value, oldValue);
732
733 if (this->removeEldestEntry(*head)) {
734 this->onEviction(*head);
735 this->remove(head->getKey());
736 }
737
738 return result;
739 }
740
741 virtual V remove(const K& key) {
742
743 LinkedHashMapEntry* toRemove = (LinkedHashMapEntry*) this->removeEntry(key);
744 if (toRemove != NULL) {
745 LinkedHashMapEntry* prev = toRemove->chainBackward;
746 LinkedHashMapEntry* next = toRemove->chainForward;
747 if (prev != NULL) {
748 prev->chainForward = next;
749 } else {
750 head = next;
751 }
752 if (next != NULL) {
753 next->chainBackward = prev;
754 } else {
755 tail = prev;
756 }
757
758 V oldValue = toRemove->getValue();
759 delete toRemove;
760 return oldValue;
761 }
762
764 __FILE__, __LINE__, "Specified key not present in the Map.");
765 }
766
768 if (this->cachedEntrySet == NULL) {
769 this->cachedEntrySet.reset(new LinkedHashMapEntrySet(this));
770 }
771 return *(this->cachedEntrySet);
772 }
773
774 virtual const Set< MapEntry<K,V> >& entrySet() const {
775 if (this->cachedConstEntrySet == NULL) {
776 this->cachedConstEntrySet.reset(new ConstLinkedHashMapEntrySet(this));
777 }
778 return *(this->cachedConstEntrySet);
779 }
780
781 virtual Set<K>& keySet() {
782 if (this->cachedKeySet == NULL) {
783 this->cachedKeySet.reset(new LinkedHashMapKeySet(this));
784 }
785 return *(this->cachedKeySet);
786 }
787
788 virtual const Set<K>& keySet() const {
789 if (this->cachedConstKeySet == NULL) {
790 this->cachedConstKeySet.reset(new ConstLinkedHashMapKeySet(this));
791 }
792 return *(this->cachedConstKeySet);
793 }
794
796 if (this->cachedValueCollection == NULL) {
797 this->cachedValueCollection.reset(new LinkedHashMapValueCollection(this));
798 }
799 return *(this->cachedValueCollection);
800 }
801
802 virtual const Collection<V>& values() const {
803 if (this->cachedConstValueCollection == NULL) {
804 this->cachedConstValueCollection.reset(new ConstLinkedHashMapValueCollection(this));
805 }
806 return *(this->cachedConstValueCollection);
807 }
808
809 virtual std::string toString() const {
810 return "LinkedHashMap";
811 }
812
813 protected:
814
815 virtual LinkedHashMapEntry* getEntry(const K& key) const {
816 LinkedHashMapEntry* result = NULL;
817
818 int hash = this->hashFunc(key);
819 int index = hash & (this->elementData.length() - 1);
820 result = (LinkedHashMapEntry*) this->findKeyEntry(key, index, hash);
821
822 if (result != NULL && accessOrder && tail != result) {
823 LinkedHashMapEntry* prev = result->chainBackward;
824 LinkedHashMapEntry* next = result->chainForward;
825 next->chainBackward = prev;
826 if (prev != NULL) {
827 prev->chainForward = next;
828 } else {
829 head = next;
830 }
831 result->chainForward = NULL;
832 result->chainBackward = tail;
833 tail->chainForward = result;
834 tail = result;
835 }
836
837 return result;
838 }
839
840 virtual typename HashMap<K, V, HASHCODE>::HashMapEntry* createEntry(const K& key, int index, const V& value) {
841 LinkedHashMapEntry* entry = new LinkedHashMapEntry(key, value);
842 entry->next = this->elementData[index];
843 this->elementData[index] = entry;
844 linkEntry(entry);
845 return entry;
846 }
847
848 virtual typename HashMap<K, V, HASHCODE>::HashMapEntry* createHashedEntry(const K& key, int index, int hash) {
849 LinkedHashMapEntry* entry = new LinkedHashMapEntry(key, V(), hash);
850 entry->next = this->elementData[index];
851 this->elementData[index] = entry;
852 linkEntry(entry);
853 return entry;
854 }
855
856 void linkEntry(LinkedHashMapEntry* entry) {
857 if (tail == entry) {
858 return;
859 }
860
861 if (head == NULL) {
862 // Check if the map is empty
863 head = tail = entry;
864 return;
865 }
866
867 // we need to link the new entry into either the head or tail
868 // of the chain depending on if the LinkedHashMap is accessOrder or not
869 LinkedHashMapEntry* prev = entry->chainBackward;
870 LinkedHashMapEntry* next = entry->chainForward;
871 if (prev == NULL) {
872 if (next != NULL) {
873 // The entry must be the head but not the tail
874 if (accessOrder) {
875 head = next;
876 next->chainBackward = NULL;
877 entry->chainBackward = tail;
878 entry->chainForward = NULL;
879 tail->chainForward = entry;
880 tail = entry;
881 }
882 } else {
883 // This is a new entry
884 entry->chainBackward = tail;
885 entry->chainForward = NULL;
886 tail->chainForward = entry;
887 tail = entry;
888 }
889 return;
890 }
891
892 if (next == NULL) {
893 // The entry must be the tail so we can't get here
894 return;
895 }
896
897 // The entry is neither the head nor tail
898 if (accessOrder) {
899 prev->chainForward = next;
900 next->chainBackward = prev;
901 entry->chainForward = NULL;
902 entry->chainBackward = tail;
903 tail->chainForward = entry;
904 tail = entry;
905 }
906 }
907
908 virtual bool putImpl(const K& key, const V& value) {
909 V oldValue;
910 return putImpl(key, value, oldValue);
911 }
912
913 virtual bool putImpl(const K& key, const V& value, V& oldValue) {
914
915 LinkedHashMapEntry* entry;
916 if (this->elementCount == 0) {
917 head = tail = NULL;
918 }
919
920 bool replaced = true;
921 int hash = this->hashFunc(key);
922 int index = hash & (this->elementData.length() - 1);
923
924 entry = (LinkedHashMapEntry*) this->findKeyEntry(key, index, hash);
925 if (entry == NULL) {
926 this->modCount++;
927 if (++this->elementCount > this->threshold) {
928 this->rehash();
929 index = hash & (this->elementData.length() - 1);
930 }
931 entry = (LinkedHashMapEntry*) this->createHashedEntry(key, index, hash);
932 replaced = false;
933 } else {
934 this->linkEntry(entry);
935 oldValue = entry->getValue();
936 }
937
938 entry->setValue(value);
939 return replaced;
940 }
941
942 };
943
944}}
945
946#endif /* _DECAF_UTIL_LINKEDHASHMAP_H_ */
Definition IllegalStateException.h:32
Definition UnsupportedOperationException.h:32
The root interface in the collection hierarchy.
Definition Collection.h:69
Definition ConcurrentModificationException.h:28
Definition HashMap.h:511
Definition HashMap.h:98
HashMapEntry * next
Definition HashMap.h:108
Definition HashMap.h:458
Definition HashMap.h:562
decaf::lang::ArrayPointer< HashMapEntry * > elementData
Definition HashMap.h:749
decaf::lang::Pointer< HashMapKeySet > cachedKeySet
Definition HashMap.h:769
int threshold
Definition HashMap.h:765
decaf::lang::Pointer< HashMapEntrySet > cachedEntrySet
Definition HashMap.h:768
virtual void clear()
Removes all of the mappings from this map (optional operation).
Definition HashMap.h:933
void rehash()
Definition HashMap.h:1208
decaf::lang::Pointer< ConstHashMapKeySet > cachedConstKeySet
Definition HashMap.h:774
HASHCODE hashFunc
The Hash Code generator for this map's keys.
Definition HashMap.h:739
HashMapEntry * findKeyEntry(const K &key, int index, int keyHash) const
Definition HashMap.h:1181
decaf::lang::Pointer< HashMapValueCollection > cachedValueCollection
Definition HashMap.h:770
HashMap()
Creates a new empty HashMap with default configuration settings.
Definition HashMap.h:805
int elementCount
Definition HashMap.h:744
void removeEntry(HashMapEntry *entry)
Definition HashMap.h:1213
decaf::lang::Pointer< ConstHashMapValueCollection > cachedConstValueCollection
Definition HashMap.h:775
int modCount
Definition HashMap.h:755
decaf::lang::Pointer< ConstHashMapEntrySet > cachedConstEntrySet
Definition HashMap.h:773
Defines an object that can be used to iterate over the elements of a collection.
Definition Iterator.h:34
virtual LinkedHashMapEntry * getEntry(const K &key) const
Definition LinkedHashMap.h:815
virtual std::string toString() const
Definition LinkedHashMap.h:809
virtual HashMap< K, V, HASHCODE >::HashMapEntry * createHashedEntry(const K &key, int index, int hash)
Definition LinkedHashMap.h:848
virtual const Collection< V > & values() const
Definition LinkedHashMap.h:802
virtual Set< MapEntry< K, V > > & entrySet()
Returns a Set view of the mappings contained in this map.
Definition LinkedHashMap.h:767
virtual bool putImpl(const K &key, const V &value)
Definition LinkedHashMap.h:908
LinkedHashMap(int capacity, float load)
Constructs a new LinkedHashMap instance with the specified capacity and load factor.
Definition LinkedHashMap.h:635
void linkEntry(LinkedHashMapEntry *entry)
Definition LinkedHashMap.h:856
virtual bool putImpl(const K &key, const V &value, V &oldValue)
Definition LinkedHashMap.h:913
LinkedHashMap(int capacity, float load, bool order)
Constructs a new LinkedHashMap instance with the specified capacity, load factor and a flag specifyin...
Definition LinkedHashMap.h:656
virtual void clear()
Removes all of the mappings from this map (optional operation).
Definition LinkedHashMap.h:713
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:719
LinkedHashMap()
Constructs an empty insertion-ordered LinkedHashMap instance with the default initial capacity (16) a...
Definition LinkedHashMap.h:609
virtual const Set< K > & keySet() const
Definition LinkedHashMap.h:788
virtual V remove(const K &key)
Removes the value (key/value pair) for the specified key from the map, returns a copy of the value th...
Definition LinkedHashMap.h:741
virtual const Set< MapEntry< K, V > > & entrySet() const
Definition LinkedHashMap.h:774
virtual Collection< V > & values()
Returns a Collection view of the values contained in this map.
Definition LinkedHashMap.h:795
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:730
virtual Set< K > & keySet()
Returns a Set view of the keys contained in this map.
Definition LinkedHashMap.h:781
LinkedHashMap(const HashMap< K, V > &map)
Constructs a new LinkedHashMap instance containing the mappings from the specified map.
Definition LinkedHashMap.h:667
virtual bool containsValue(const V &value) const
Returns true if this map maps one or more keys to the specified value.
Definition LinkedHashMap.h:702
LinkedHashMap(int capacity)
Constructs a new LinkedHashMap instance with the specified capacity.
Definition LinkedHashMap.h:620
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:698
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:685
virtual ~LinkedHashMap()
Definition LinkedHashMap.h:670
virtual HashMap< K, V, HASHCODE >::HashMapEntry * createEntry(const K &key, int index, const V &value)
Definition LinkedHashMap.h:840
Definition MapEntry.h:27
virtual void setValue(const V &value)
Definition MapEntry.h:65
virtual K & getKey()
Definition MapEntry.h:57
virtual V & getValue()
Definition MapEntry.h:69
Definition NoSuchElementException.h:31
A collection that contains no duplicate elements.
Definition Set.h:45
#define NULL
Definition Config.h:33
Definition AbstractCollection.h:33
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition AprPool.h:25