public class SequencedHashMap
extends java.lang.Object
implements java.util.Map, java.lang.Cloneable, java.io.Externalizable
Although this map is sequenced, it cannot implement
List
because of incompatible interface definitions.
The remove methods in List and Map have different return values
(see: List.remove(Object)
and Map.remove(Object)
).
This class is not thread safe. When a thread safe implementation is
required, use Collections.synchronizedMap(Map)
as it is documented,
or use explicit synchronization controls.
LinkedMap
,
ListOrderedMap
,
Serialized FormConstructor and Description |
---|
SequencedHashMap()
Deprecated.
Construct a new sequenced hash map with default initial size and load
factor.
|
SequencedHashMap(int initialSize)
Deprecated.
Construct a new sequenced hash map with the specified initial size and
default load factor.
|
SequencedHashMap(int initialSize,
float loadFactor)
Deprecated.
Construct a new sequenced hash map with the specified initial size and
load factor.
|
SequencedHashMap(java.util.Map m)
Deprecated.
Construct a new sequenced hash map and add all the elements in the
specified map.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Deprecated.
Implements
Map.clear() . |
java.lang.Object |
clone()
Deprecated.
Creates a shallow copy of this object, preserving the internal structure
by copying only references.
|
boolean |
containsKey(java.lang.Object key)
Deprecated.
Implements
Map.containsKey(Object) . |
boolean |
containsValue(java.lang.Object value)
Deprecated.
Implements
Map.containsValue(Object) . |
java.util.Set |
entrySet()
Deprecated.
Implements
Map.entrySet() . |
boolean |
equals(java.lang.Object obj)
Deprecated.
Implements
Map.equals(Object) . |
java.lang.Object |
get(int index)
Deprecated.
Gets the key at the specified index.
|
java.lang.Object |
get(java.lang.Object o)
Deprecated.
Implements
Map.get(Object) . |
java.util.Map.Entry |
getFirst()
Deprecated.
Return the entry for the "oldest" mapping.
|
java.lang.Object |
getFirstKey()
Deprecated.
Return the key for the "oldest" mapping.
|
java.lang.Object |
getFirstValue()
Deprecated.
Return the value for the "oldest" mapping.
|
java.util.Map.Entry |
getLast()
Deprecated.
Return the entry for the "newest" mapping.
|
java.lang.Object |
getLastKey()
Deprecated.
Return the key for the "newest" mapping.
|
java.lang.Object |
getLastValue()
Deprecated.
Return the value for the "newest" mapping.
|
java.lang.Object |
getValue(int index)
Deprecated.
Gets the value at the specified index.
|
int |
hashCode()
Deprecated.
Implements
Map.hashCode() . |
int |
indexOf(java.lang.Object key)
Deprecated.
Gets the index of the specified key.
|
boolean |
isEmpty()
Deprecated.
Implements
Map.isEmpty() . |
java.util.Iterator |
iterator()
Deprecated.
Gets an iterator over the keys.
|
java.util.Set |
keySet()
Deprecated.
Implements
Map.keySet() . |
int |
lastIndexOf(java.lang.Object key)
Deprecated.
Gets the last index of the specified key.
|
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Deprecated.
Implements
Map.put(Object, Object) . |
void |
putAll(java.util.Map t)
Deprecated.
Adds all the mappings in the specified map to this map, replacing any
mappings that already exist (as per
Map.putAll(Map) ). |
void |
readExternal(java.io.ObjectInput in)
Deprecated.
Deserializes this map from the given stream.
|
java.lang.Object |
remove(int index)
Deprecated.
Removes the element at the specified index.
|
java.lang.Object |
remove(java.lang.Object key)
Deprecated.
Implements
Map.remove(Object) . |
java.util.List |
sequence()
Deprecated.
Returns a List view of the keys rather than a set view.
|
int |
size()
Deprecated.
Implements
Map.size() . |
java.lang.String |
toString()
Deprecated.
Provides a string representation of the entries within the map.
|
java.util.Collection |
values()
Deprecated.
Implements
Map.values() . |
void |
writeExternal(java.io.ObjectOutput out)
Deprecated.
Serializes this map to the given stream.
|
public SequencedHashMap()
public SequencedHashMap(int initialSize)
initialSize
- the initial size for the hash tableHashMap.HashMap(int)
public SequencedHashMap(int initialSize, float loadFactor)
initialSize
- the initial size for the hash tableloadFactor
- the load factor for the hash table.HashMap.HashMap(int,float)
public SequencedHashMap(java.util.Map m)
putAll(Map)
.public int size()
Map.size()
.size
in interface java.util.Map
public boolean isEmpty()
Map.isEmpty()
.isEmpty
in interface java.util.Map
public boolean containsKey(java.lang.Object key)
Map.containsKey(Object)
.containsKey
in interface java.util.Map
public boolean containsValue(java.lang.Object value)
Map.containsValue(Object)
.containsValue
in interface java.util.Map
public java.lang.Object get(java.lang.Object o)
Map.get(Object)
.get
in interface java.util.Map
public java.util.Map.Entry getFirst()
entrySet().iterator().next()
, but this method provides an
optimized implementation.null
if the
map is empty.public java.lang.Object getFirstKey()
getFirst().getKey()
, but this method provides a slightly
optimized implementation.null
if the
map is empty.public java.lang.Object getFirstValue()
getFirst().getValue()
, but this method provides a slightly
optimized implementation.null
if the
map is empty.public java.util.Map.Entry getLast()
Object obj = null; Iterator iter = entrySet().iterator(); while(iter.hasNext()) { obj = iter.next(); } return (Map.Entry)obj;However, the implementation of this method ensures an O(1) lookup of the last key rather than O(n).
null
if the map
is empty.public java.lang.Object getLastKey()
getLast().getKey()
, but this method provides a slightly
optimized implementation.null
if the map is
empty.public java.lang.Object getLastValue()
getLast().getValue()
, but this method provides a slightly
optimized implementation.null
if the map
is empty.public java.lang.Object put(java.lang.Object key, java.lang.Object value)
Map.put(Object, Object)
.put
in interface java.util.Map
public java.lang.Object remove(java.lang.Object key)
Map.remove(Object)
.remove
in interface java.util.Map
public void putAll(java.util.Map t)
Map.putAll(Map)
). The order
in which the entries are added is determined by the iterator returned
from Map.entrySet()
for the specified map.putAll
in interface java.util.Map
t
- the mappings that should be added to this map.java.lang.NullPointerException
- if t
is null
public void clear()
Map.clear()
.clear
in interface java.util.Map
public boolean equals(java.lang.Object obj)
Map.equals(Object)
.equals
in interface java.util.Map
equals
in class java.lang.Object
public int hashCode()
Map.hashCode()
.hashCode
in interface java.util.Map
hashCode
in class java.lang.Object
public java.lang.String toString()
entrySet()
.iterator()
and
iterate over the entries in the map formatting them as appropriate.toString
in class java.lang.Object
public java.util.Set keySet()
Map.keySet()
.keySet
in interface java.util.Map
public java.util.Collection values()
Map.values()
.values
in interface java.util.Map
public java.util.Set entrySet()
Map.entrySet()
.entrySet
in interface java.util.Map
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone()
'd. The cloned object maintains the same sequence.clone
in class java.lang.Object
java.lang.CloneNotSupportedException
- if clone is not supported by a
subclass.public java.lang.Object get(int index)
index
- the index to retrievejava.lang.ArrayIndexOutOfBoundsException
- if the index
is
< 0
or >
the size of the map.public java.lang.Object getValue(int index)
index
- the index to retrievejava.lang.ArrayIndexOutOfBoundsException
- if the index
is
< 0
or >
the size of the map.public int indexOf(java.lang.Object key)
key
- the key to find the index ofpublic java.util.Iterator iterator()
public int lastIndexOf(java.lang.Object key)
key
- the key to find the index ofpublic java.util.List sequence()
ListIterator.set(Object)
) will
effectively remove the value from the list and reinsert that value at
the end of the list, which is an unexpected side effect of changing the
value of a list. This occurs because changing the key, changes when the
mapping is added to the map and thus where it appears in the list.
An alternative to this method is to use keySet()
keySet()
public java.lang.Object remove(int index)
index
- The index of the object to remove.key
, or
null
if none existed.java.lang.ArrayIndexOutOfBoundsException
- if the index
is
< 0
or >
the size of the map.public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
readExternal
in interface java.io.Externalizable
in
- the stream to deserialize fromjava.io.IOException
- if the stream raises itjava.lang.ClassNotFoundException
- if the stream raises itpublic void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
out
- the stream to serialize tojava.io.IOException
- if the stream raises it"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"