Class DoubleOrderedMap
- java.lang.Object
-
- java.util.AbstractMap
-
- org.apache.commons.collections.DoubleOrderedMap
-
- All Implemented Interfaces:
java.util.Map
public final class DoubleOrderedMap extends java.util.AbstractMapDeprecated.Replaced by TreeBidiMap in bidimap subpackage. Due to be removed in v4.0.Red-Black tree-based implementation of Map. This class guarantees that the map will be in both ascending key order and ascending value order, sorted according to the natural order for the key's and value's classes.This Map is intended for applications that need to be able to look up a key-value pairing by either key or value, and need to do so with equal efficiency.
While that goal could be accomplished by taking a pair of TreeMaps and redirecting requests to the appropriate TreeMap (e.g., containsKey would be directed to the TreeMap that maps values to keys, containsValue would be directed to the TreeMap that maps keys to values), there are problems with that implementation, particularly when trying to keep the two TreeMaps synchronized with each other. And if the data contained in the TreeMaps is large, the cost of redundant storage becomes significant. (See also the new
DualTreeBidiMapandDualHashBidiMapimplementations.)This solution keeps the data properly synchronized and minimizes the data storage. The red-black algorithm is based on TreeMap's, but has been modified to simultaneously map a tree node by key and by value. This doubles the cost of put operations (but so does using two TreeMaps), and nearly doubles the cost of remove operations (there is a savings in that the lookup of the node to be removed only has to be performed once). And since only one node contains the key and value, storage is significantly less than that required by two TreeMaps.
There are some limitations placed on data kept in this Map. The biggest one is this:
When performing a put operation, neither the key nor the value may already exist in the Map. In the java.util Map implementations (HashMap, TreeMap), you can perform a put with an already mapped key, and neither cares about duplicate values at all ... but this implementation's put method with throw an IllegalArgumentException if either the key or the value is already in the Map.
Obviously, that same restriction (and consequence of failing to heed that restriction) applies to the putAll method.
The Map.Entry instances returned by the appropriate methods will not allow setValue() and will throw an UnsupportedOperationException on attempts to call that method.
New methods are added to take advantage of the fact that values are kept sorted independently of their keys:
Object getKeyForValue(Object value) is the opposite of get; it takes a value and returns its key, if any.
Object removeValue(Object value) finds and removes the specified value and returns the now un-used key.
Set entrySetByValue() returns the Map.Entry's in a Set whose iterator will iterate over the Map.Entry's in ascending order by their corresponding values.
Set keySetByValue() returns the keys in a Set whose iterator will iterate over the keys in ascending order by their corresponding values.
Collection valuesByValue() returns the values in a Collection whose iterator will iterate over the values in ascending order.
- Since:
- Commons Collections 2.0
- Version:
- $Revision: 646777 $ $Date: 2008-04-10 14:33:15 +0200 (Thu, 10 Apr 2008) $
- See Also:
BidiMap,DualTreeBidiMap,DualHashBidiMap
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classDoubleOrderedMap.DoubleOrderedMapIteratorDeprecated.private static classDoubleOrderedMap.NodeDeprecated.
-
Field Summary
Fields Modifier and Type Field Description private java.util.Collection[]collectionOfValuesDeprecated.private static java.lang.String[]dataNameDeprecated.private static intFIRST_INDEXDeprecated.private static intKEYDeprecated.private intmodificationsDeprecated.private intnodeCountDeprecated.private static intNUMBER_OF_INDICESDeprecated.private DoubleOrderedMap.Node[]rootNodeDeprecated.private java.util.Set[]setOfEntriesDeprecated.private java.util.Set[]setOfKeysDeprecated.private static intSUM_OF_INDICESDeprecated.private static intVALUEDeprecated.
-
Constructor Summary
Constructors Constructor Description DoubleOrderedMap()Deprecated.Construct a new DoubleOrderedMapDoubleOrderedMap(java.util.Map map)Deprecated.Constructs a new DoubleOrderedMap from an existing Map, with keys and values sorted
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private static voidcheckKey(java.lang.Object key)Deprecated.check a key for validity (non-null and implements Comparable)private static voidcheckKeyAndValue(java.lang.Object key, java.lang.Object value)Deprecated.check a key and a value for validity (non-null and implements Comparable)private static voidcheckNonNullComparable(java.lang.Object o, int index)Deprecated.check if an object is fit to be proper input ...private static voidcheckValue(java.lang.Object value)Deprecated.check a value for validity (non-null and implements Comparable)voidclear()Deprecated.Removes all mappings from this mapprivate static intcompare(java.lang.Comparable o1, java.lang.Comparable o2)Deprecated.Compare two objectsbooleancontainsKey(java.lang.Object key)Deprecated.Returns true if this map contains a mapping for the specified key.booleancontainsValue(java.lang.Object value)Deprecated.Returns true if this map maps one or more keys to the specified value.private static voidcopyColor(DoubleOrderedMap.Node from, DoubleOrderedMap.Node to, int index)Deprecated.copy the color from one node to another, dealing with the fact that one or both nodes may, in fact, be nullprivate java.lang.ObjectdoGet(java.lang.Comparable o, int index)Deprecated.common get logic, used to get by key or get by valueprivate voiddoRedBlackDelete(DoubleOrderedMap.Node deletedNode)Deprecated.complicated red-black delete stuff.private voiddoRedBlackDeleteFixup(DoubleOrderedMap.Node replacementNode, int index)Deprecated.complicated red-black delete stuff.private voiddoRedBlackInsert(DoubleOrderedMap.Node insertedNode, int index)Deprecated.complicated red-black insert stuff.private java.lang.ObjectdoRemove(java.lang.Comparable o, int index)Deprecated.common remove logic (remove by key or remove by value)java.util.SetentrySet()Deprecated.Returns a set view of the mappings contained in this map.java.util.SetentrySetByValue()Deprecated.Returns a set view of the mappings contained in this map.java.lang.Objectget(java.lang.Object key)Deprecated.Returns the value to which this map maps the specified key.private static DoubleOrderedMap.NodegetGrandParent(DoubleOrderedMap.Node node, int index)Deprecated.get a node's grandparent.java.lang.ObjectgetKeyForValue(java.lang.Object value)Deprecated.Returns the key to which this map maps the specified value.private static DoubleOrderedMap.NodegetLeftChild(DoubleOrderedMap.Node node, int index)Deprecated.get a node's left child.private static DoubleOrderedMap.NodegetParent(DoubleOrderedMap.Node node, int index)Deprecated.get a node's parent.private static DoubleOrderedMap.NodegetRightChild(DoubleOrderedMap.Node node, int index)Deprecated.get a node's right child.private voidgrow()Deprecated.bump up the size and note that the map has changedprivate voidinsertValue(DoubleOrderedMap.Node newNode)Deprecated.insert a node by its valueprivate static booleanisBlack(DoubleOrderedMap.Node node, int index)Deprecated.is the specified black red? if the node does not exist, sure, it's black, thank youprivate static booleanisLeftChild(DoubleOrderedMap.Node node, int index)Deprecated.is this node its parent's left child? mind you, the node, or its parent, may not exist.private static booleanisRed(DoubleOrderedMap.Node node, int index)Deprecated.is the specified node red? if the node does not exist, no, it's black, thank youprivate static booleanisRightChild(DoubleOrderedMap.Node node, int index)Deprecated.is this node its parent's right child? mind you, the node, or its parent, may not exist.java.util.SetkeySet()Deprecated.Returns a set view of the keys contained in this map.java.util.SetkeySetByValue()Deprecated.Returns a set view of the keys contained in this map.private static DoubleOrderedMap.NodeleastNode(DoubleOrderedMap.Node node, int index)Deprecated.find the least node from a given node.private DoubleOrderedMap.Nodelookup(java.lang.Comparable data, int index)Deprecated.do the actual lookup of a piece of dataprivate static voidmakeBlack(DoubleOrderedMap.Node node, int index)Deprecated.force a node (if it exists) blackprivate static voidmakeRed(DoubleOrderedMap.Node node, int index)Deprecated.force a node (if it exists) redprivate voidmodify()Deprecated.increment the modification count -- used to check for concurrent modification of the map through the map and through an Iterator from one of its Set or Collection viewsprivate DoubleOrderedMap.NodenextGreater(DoubleOrderedMap.Node node, int index)Deprecated.get the next larger node from the specified nodeprivate intoppositeIndex(int index)Deprecated.Get the opposite index of the specified indexjava.lang.Objectput(java.lang.Object key, java.lang.Object value)Deprecated.Associates the specified value with the specified key in this map.java.lang.Objectremove(java.lang.Object key)Deprecated.Removes the mapping for this key from this map if presentjava.lang.ObjectremoveValue(java.lang.Object value)Deprecated.Removes the mapping for this value from this map if presentprivate voidrotateLeft(DoubleOrderedMap.Node node, int index)Deprecated.do a rotate left.private voidrotateRight(DoubleOrderedMap.Node node, int index)Deprecated.do a rotate right.private voidshrink()Deprecated.decrement the size and note that the map has changedintsize()Deprecated.Returns the number of key-value mappings in this map.private voidswapPosition(DoubleOrderedMap.Node x, DoubleOrderedMap.Node y, int index)Deprecated.swap two nodes (except for their content), taking care of special cases where one is the other's parent ...java.util.Collectionvalues()Deprecated.Returns a collection view of the values contained in this map.java.util.CollectionvaluesByValue()Deprecated.Returns a collection view of the values contained in this map.-
Methods inherited from class java.util.AbstractMap
clone, equals, hashCode, isEmpty, putAll, toString
-
-
-
-
Field Detail
-
KEY
private static final int KEY
Deprecated.- See Also:
- Constant Field Values
-
VALUE
private static final int VALUE
Deprecated.- See Also:
- Constant Field Values
-
SUM_OF_INDICES
private static final int SUM_OF_INDICES
Deprecated.- See Also:
- Constant Field Values
-
FIRST_INDEX
private static final int FIRST_INDEX
Deprecated.- See Also:
- Constant Field Values
-
NUMBER_OF_INDICES
private static final int NUMBER_OF_INDICES
Deprecated.- See Also:
- Constant Field Values
-
dataName
private static final java.lang.String[] dataName
Deprecated.
-
rootNode
private DoubleOrderedMap.Node[] rootNode
Deprecated.
-
nodeCount
private int nodeCount
Deprecated.
-
modifications
private int modifications
Deprecated.
-
setOfKeys
private java.util.Set[] setOfKeys
Deprecated.
-
setOfEntries
private java.util.Set[] setOfEntries
Deprecated.
-
collectionOfValues
private java.util.Collection[] collectionOfValues
Deprecated.
-
-
Constructor Detail
-
DoubleOrderedMap
public DoubleOrderedMap()
Deprecated.Construct a new DoubleOrderedMap
-
DoubleOrderedMap
public DoubleOrderedMap(java.util.Map map) throws java.lang.ClassCastException, java.lang.NullPointerException, java.lang.IllegalArgumentExceptionDeprecated.Constructs a new DoubleOrderedMap from an existing Map, with keys and values sorted- Parameters:
map- the map whose mappings are to be placed in this map.- Throws:
java.lang.ClassCastException- if the keys in the map are not Comparable, or are not mutually comparable; also if the values in the map are not Comparable, or are not mutually Comparablejava.lang.NullPointerException- if any key or value in the map is nulljava.lang.IllegalArgumentException- if there are duplicate keys or duplicate values in the map
-
-
Method Detail
-
getKeyForValue
public java.lang.Object getKeyForValue(java.lang.Object value) throws java.lang.ClassCastException, java.lang.NullPointerExceptionDeprecated.Returns the key to which this map maps the specified value. Returns null if the map contains no mapping for this value.- Parameters:
value- value whose associated key is to be returned.- Returns:
- the key to which this map maps the specified value, or null if the map contains no mapping for this value.
- Throws:
java.lang.ClassCastException- if the value is of an inappropriate type for this map.java.lang.NullPointerException- if the value is null
-
removeValue
public java.lang.Object removeValue(java.lang.Object value)
Deprecated.Removes the mapping for this value from this map if present- Parameters:
value- value whose mapping is to be removed from the map.- Returns:
- previous key associated with specified value, or null if there was no mapping for value.
-
entrySetByValue
public java.util.Set entrySetByValue()
Deprecated.Returns a set view of the mappings contained in this map. Each element in the returned set is a Map.Entry. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress, the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.The difference between this method and entrySet is that entrySet's iterator() method returns an iterator that iterates over the mappings in ascending order by key. This method's iterator method iterates over the mappings in ascending order by value.
- Returns:
- a set view of the mappings contained in this map.
-
keySetByValue
public java.util.Set keySetByValue()
Deprecated.Returns a set view of the keys contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress, the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll, and clear operations. It does not support the add or addAll operations.The difference between this method and keySet is that keySet's iterator() method returns an iterator that iterates over the keys in ascending order by key. This method's iterator method iterates over the keys in ascending order by value.
- Returns:
- a set view of the keys contained in this map.
-
valuesByValue
public java.util.Collection valuesByValue()
Deprecated.Returns a collection view of the values contained in this map. The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa. If the map is modified while an iteration over the collection is in progress, the results of the iteration are undefined. The collection supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Collection.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.The difference between this method and values is that values's iterator() method returns an iterator that iterates over the values in ascending order by key. This method's iterator method iterates over the values in ascending order by key.
- Returns:
- a collection view of the values contained in this map.
-
doRemove
private java.lang.Object doRemove(java.lang.Comparable o, int index)Deprecated.common remove logic (remove by key or remove by value)- Parameters:
o- the key, or value, that we're looking forindex- KEY or VALUE- Returns:
- the key, if remove by value, or the value, if remove by key. null if the specified key or value could not be found
-
doGet
private java.lang.Object doGet(java.lang.Comparable o, int index)Deprecated.common get logic, used to get by key or get by value- Parameters:
o- the key or value that we're looking forindex- KEY or VALUE- Returns:
- the key (if the value was mapped) or the value (if the key was mapped); null if we couldn't find the specified object
-
oppositeIndex
private int oppositeIndex(int index)
Deprecated.Get the opposite index of the specified index- Parameters:
index- KEY or VALUE- Returns:
- VALUE (if KEY was specified), else KEY
-
lookup
private DoubleOrderedMap.Node lookup(java.lang.Comparable data, int index)
Deprecated.do the actual lookup of a piece of data- Parameters:
data- the key or value to be looked upindex- KEY or VALUE- Returns:
- the desired Node, or null if there is no mapping of the specified data
-
compare
private static int compare(java.lang.Comparable o1, java.lang.Comparable o2)Deprecated.Compare two objects- Parameters:
o1- the first objecto2- the second object- Returns:
- negative value if o1 < o2; 0 if o1 == o2; positive value if o1 > o2
-
leastNode
private static DoubleOrderedMap.Node leastNode(DoubleOrderedMap.Node node, int index)
Deprecated.find the least node from a given node. very useful for starting a sorting iterator ...- Parameters:
node- the node from which we will start searchingindex- KEY or VALUE- Returns:
- the smallest node, from the specified node, in the specified mapping
-
nextGreater
private DoubleOrderedMap.Node nextGreater(DoubleOrderedMap.Node node, int index)
Deprecated.get the next larger node from the specified node- Parameters:
node- the node to be searched fromindex- KEY or VALUE- Returns:
- the specified node
-
copyColor
private static void copyColor(DoubleOrderedMap.Node from, DoubleOrderedMap.Node to, int index)
Deprecated.copy the color from one node to another, dealing with the fact that one or both nodes may, in fact, be null- Parameters:
from- the node whose color we're copying; may be nullto- the node whose color we're changing; may be nullindex- KEY or VALUE
-
isRed
private static boolean isRed(DoubleOrderedMap.Node node, int index)
Deprecated.is the specified node red? if the node does not exist, no, it's black, thank you- Parameters:
node- the node (may be null) in questionindex- KEY or VALUE
-
isBlack
private static boolean isBlack(DoubleOrderedMap.Node node, int index)
Deprecated.is the specified black red? if the node does not exist, sure, it's black, thank you- Parameters:
node- the node (may be null) in questionindex- KEY or VALUE
-
makeRed
private static void makeRed(DoubleOrderedMap.Node node, int index)
Deprecated.force a node (if it exists) red- Parameters:
node- the node (may be null) in questionindex- KEY or VALUE
-
makeBlack
private static void makeBlack(DoubleOrderedMap.Node node, int index)
Deprecated.force a node (if it exists) black- Parameters:
node- the node (may be null) in questionindex- KEY or VALUE
-
getGrandParent
private static DoubleOrderedMap.Node getGrandParent(DoubleOrderedMap.Node node, int index)
Deprecated.get a node's grandparent. mind you, the node, its parent, or its grandparent may not exist. no problem- Parameters:
node- the node (may be null) in questionindex- KEY or VALUE
-
getParent
private static DoubleOrderedMap.Node getParent(DoubleOrderedMap.Node node, int index)
Deprecated.get a node's parent. mind you, the node, or its parent, may not exist. no problem- Parameters:
node- the node (may be null) in questionindex- KEY or VALUE
-
getRightChild
private static DoubleOrderedMap.Node getRightChild(DoubleOrderedMap.Node node, int index)
Deprecated.get a node's right child. mind you, the node may not exist. no problem- Parameters:
node- the node (may be null) in questionindex- KEY or VALUE
-
getLeftChild
private static DoubleOrderedMap.Node getLeftChild(DoubleOrderedMap.Node node, int index)
Deprecated.get a node's left child. mind you, the node may not exist. no problem- Parameters:
node- the node (may be null) in questionindex- KEY or VALUE
-
isLeftChild
private static boolean isLeftChild(DoubleOrderedMap.Node node, int index)
Deprecated.is this node its parent's left child? mind you, the node, or its parent, may not exist. no problem. if the node doesn't exist ... it's its non-existent parent's left child. If the node does exist but has no parent ... no, we're not the non-existent parent's left child. Otherwise (both the specified node AND its parent exist), check.- Parameters:
node- the node (may be null) in questionindex- KEY or VALUE
-
isRightChild
private static boolean isRightChild(DoubleOrderedMap.Node node, int index)
Deprecated.is this node its parent's right child? mind you, the node, or its parent, may not exist. no problem. if the node doesn't exist ... it's its non-existent parent's right child. If the node does exist but has no parent ... no, we're not the non-existent parent's right child. Otherwise (both the specified node AND its parent exist), check.- Parameters:
node- the node (may be null) in questionindex- KEY or VALUE
-
rotateLeft
private void rotateLeft(DoubleOrderedMap.Node node, int index)
Deprecated.do a rotate left. standard fare in the world of balanced trees- Parameters:
node- the node to be rotatedindex- KEY or VALUE
-
rotateRight
private void rotateRight(DoubleOrderedMap.Node node, int index)
Deprecated.do a rotate right. standard fare in the world of balanced trees- Parameters:
node- the node to be rotatedindex- KEY or VALUE
-
doRedBlackInsert
private void doRedBlackInsert(DoubleOrderedMap.Node insertedNode, int index)
Deprecated.complicated red-black insert stuff. Based on Sun's TreeMap implementation, though it's barely recognizable any more- Parameters:
insertedNode- the node to be insertedindex- KEY or VALUE
-
doRedBlackDelete
private void doRedBlackDelete(DoubleOrderedMap.Node deletedNode)
Deprecated.complicated red-black delete stuff. Based on Sun's TreeMap implementation, though it's barely recognizable any more- Parameters:
deletedNode- the node to be deleted
-
doRedBlackDeleteFixup
private void doRedBlackDeleteFixup(DoubleOrderedMap.Node replacementNode, int index)
Deprecated.complicated red-black delete stuff. Based on Sun's TreeMap implementation, though it's barely recognizable any more. This rebalances the tree (somewhat, as red-black trees are not perfectly balanced -- perfect balancing takes longer)- Parameters:
replacementNode- the node being replacedindex- KEY or VALUE
-
swapPosition
private void swapPosition(DoubleOrderedMap.Node x, DoubleOrderedMap.Node y, int index)
Deprecated.swap two nodes (except for their content), taking care of special cases where one is the other's parent ... hey, it happens.- Parameters:
x- one nodey- another nodeindex- KEY or VALUE
-
checkNonNullComparable
private static void checkNonNullComparable(java.lang.Object o, int index)Deprecated.check if an object is fit to be proper input ... has to be Comparable and non-null- Parameters:
o- the object being checkedindex- KEY or VALUE (used to put the right word in the exception message)- Throws:
java.lang.NullPointerException- if o is nulljava.lang.ClassCastException- if o is not Comparable
-
checkKey
private static void checkKey(java.lang.Object key)
Deprecated.check a key for validity (non-null and implements Comparable)- Parameters:
key- the key to be checked- Throws:
java.lang.NullPointerException- if key is nulljava.lang.ClassCastException- if key is not Comparable
-
checkValue
private static void checkValue(java.lang.Object value)
Deprecated.check a value for validity (non-null and implements Comparable)- Parameters:
value- the value to be checked- Throws:
java.lang.NullPointerException- if value is nulljava.lang.ClassCastException- if value is not Comparable
-
checkKeyAndValue
private static void checkKeyAndValue(java.lang.Object key, java.lang.Object value)Deprecated.check a key and a value for validity (non-null and implements Comparable)- Parameters:
key- the key to be checkedvalue- the value to be checked- Throws:
java.lang.NullPointerException- if key or value is nulljava.lang.ClassCastException- if key or value is not Comparable
-
modify
private void modify()
Deprecated.increment the modification count -- used to check for concurrent modification of the map through the map and through an Iterator from one of its Set or Collection views
-
grow
private void grow()
Deprecated.bump up the size and note that the map has changed
-
shrink
private void shrink()
Deprecated.decrement the size and note that the map has changed
-
insertValue
private void insertValue(DoubleOrderedMap.Node newNode) throws java.lang.IllegalArgumentException
Deprecated.insert a node by its value- Parameters:
newNode- the node to be inserted- Throws:
java.lang.IllegalArgumentException- if the node already exists in the value mapping
-
size
public int size()
Deprecated.Returns the number of key-value mappings in this map. If the map contains more than Integer.MAXVALUE elements, returns Integer.MAXVALUE.- Specified by:
sizein interfacejava.util.Map- Overrides:
sizein classjava.util.AbstractMap- Returns:
- the number of key-value mappings in this map.
-
containsKey
public boolean containsKey(java.lang.Object key) throws java.lang.ClassCastException, java.lang.NullPointerExceptionDeprecated.Returns true if this map contains a mapping for the specified key.- Specified by:
containsKeyin interfacejava.util.Map- Overrides:
containsKeyin classjava.util.AbstractMap- Parameters:
key- key whose presence in this map is to be tested.- Returns:
- true if this map contains a mapping for the specified key.
- Throws:
java.lang.ClassCastException- if the key is of an inappropriate type for this map.java.lang.NullPointerException- if the key is null
-
containsValue
public boolean containsValue(java.lang.Object value)
Deprecated.Returns true if this map maps one or more keys to the specified value.- Specified by:
containsValuein interfacejava.util.Map- Overrides:
containsValuein classjava.util.AbstractMap- Parameters:
value- value whose presence in this map is to be tested.- Returns:
- true if this map maps one or more keys to the specified value.
-
get
public java.lang.Object get(java.lang.Object key) throws java.lang.ClassCastException, java.lang.NullPointerExceptionDeprecated.Returns the value to which this map maps the specified key. Returns null if the map contains no mapping for this key.- Specified by:
getin interfacejava.util.Map- Overrides:
getin classjava.util.AbstractMap- Parameters:
key- key whose associated value is to be returned.- Returns:
- the value to which this map maps the specified key, or null if the map contains no mapping for this key.
- Throws:
java.lang.ClassCastException- if the key is of an inappropriate type for this map.java.lang.NullPointerException- if the key is null
-
put
public java.lang.Object put(java.lang.Object key, java.lang.Object value) throws java.lang.ClassCastException, java.lang.NullPointerException, java.lang.IllegalArgumentExceptionDeprecated.Associates the specified value with the specified key in this map.- Specified by:
putin interfacejava.util.Map- Overrides:
putin classjava.util.AbstractMap- Parameters:
key- key with which the specified value is to be associated.value- value to be associated with the specified key.- Returns:
- null
- Throws:
java.lang.ClassCastException- if the class of the specified key or value prevents it from being stored in this map.java.lang.NullPointerException- if the specified key or value is nulljava.lang.IllegalArgumentException- if the key duplicates an existing key, or if the value duplicates an existing value
-
remove
public java.lang.Object remove(java.lang.Object key)
Deprecated.Removes the mapping for this key from this map if present- Specified by:
removein interfacejava.util.Map- Overrides:
removein classjava.util.AbstractMap- Parameters:
key- key whose mapping is to be removed from the map.- Returns:
- previous value associated with specified key, or null if there was no mapping for key.
-
clear
public void clear()
Deprecated.Removes all mappings from this map- Specified by:
clearin interfacejava.util.Map- Overrides:
clearin classjava.util.AbstractMap
-
keySet
public java.util.Set keySet()
Deprecated.Returns a set view of the keys contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress, the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll, and clear operations. It does not support the add or addAll operations.- Specified by:
keySetin interfacejava.util.Map- Overrides:
keySetin classjava.util.AbstractMap- Returns:
- a set view of the keys contained in this map.
-
values
public java.util.Collection values()
Deprecated.Returns a collection view of the values contained in this map. The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa. If the map is modified while an iteration over the collection is in progress, the results of the iteration are undefined. The collection supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Collection.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.- Specified by:
valuesin interfacejava.util.Map- Overrides:
valuesin classjava.util.AbstractMap- Returns:
- a collection view of the values contained in this map.
-
entrySet
public java.util.Set entrySet()
Deprecated.Returns a set view of the mappings contained in this map. Each element in the returned set is a Map.Entry. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress, the results of the iteration are undefined.The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations. The setValue method is not supported on the Map Entry.
- Specified by:
entrySetin interfacejava.util.Map- Specified by:
entrySetin classjava.util.AbstractMap- Returns:
- a set view of the mappings contained in this map.
-
-