Package com.cedarsoftware.util
Class TrackingMap<K,V>
java.lang.Object
com.cedarsoftware.util.TrackingMap<K,V>
- All Implemented Interfaces:
Map<K,
V>
TrackingMap
- Author:
- Sean Kellner
Copyright (c) Cedar Software LLC
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
License
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-
Nested Class Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
boolean
containsKey
(Object key) boolean
containsValue
(Object value) entrySet()
boolean
void
Remove the entries from the Map that have not been accessed by .get() or .containsKey().Fetch the Map that this TrackingMap wraps.int
hashCode()
void
informAdditionalUsage
(TrackingMap<K, V> additional) Add the used keys from the passed in TrackingMap to this TrackingMap's keysUsed.void
informAdditionalUsage
(Collection<K> additional) Add the Collection of keys to the internal list of keys accessed.boolean
isEmpty()
keySet()
keysUsed()
Fetch the Set of keys that have been accessed via .get() or .containsKey() of the contained Map.void
int
size()
toString()
values()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
TrackingMap
Wrap the passed in Map with a TrackingMap.- Parameters:
map
- Map to wrap
-
-
Method Details
-
get
-
put
-
containsKey
- Specified by:
containsKey
in interfaceMap<K,
V>
-
putAll
-
remove
-
size
public int size() -
isEmpty
public boolean isEmpty() -
equals
-
hashCode
public int hashCode() -
toString
-
clear
public void clear() -
containsValue
- Specified by:
containsValue
in interfaceMap<K,
V>
-
values
-
keySet
-
entrySet
-
expungeUnused
public void expungeUnused()Remove the entries from the Map that have not been accessed by .get() or .containsKey(). -
informAdditionalUsage
Add the Collection of keys to the internal list of keys accessed. If there are keys in the passed in Map that are not included in the contained Map, the readKeys will exceed the keySet() of the wrapped Map.- Parameters:
additional
- Collection of keys to add to the list of keys read.
-
informAdditionalUsage
Add the used keys from the passed in TrackingMap to this TrackingMap's keysUsed. This can cause the readKeys to include entries that are not in wrapped Maps keys.- Parameters:
additional
- TrackingMap whose used keys are to be added to this maps used keys.
-
keysUsed
Fetch the Set of keys that have been accessed via .get() or .containsKey() of the contained Map.- Returns:
- Set of the accessed (read) keys.
-
getWrappedMap
Fetch the Map that this TrackingMap wraps.- Returns:
- Map the wrapped Map
-