|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractMap
com.arsdigita.util.SequentialMap
A map that keeps its entries in a fixed sequence. All iterators returned
by this class, for example by entrySet().iterator()
, are
guaranteed to return the entries in the order in which they were put in
the map. This implementation allows null
for both the key
or the associated value for a map entry.
Almost all of the map operations, for example get
or containsKey
require time linear in the size of the map,
making this map only suitable for small map sizes.
Nested Class Summary |
Nested classes inherited from class java.util.Map |
Map.Entry |
Field Summary | |
static String |
versionId
|
Constructor Summary | |
SequentialMap()
Creates an empty SequentialMap . |
Method Summary | |
void |
clear()
Removes all mappings from this map. |
boolean |
containsKey(Object key)
Returns true if this map contains a mapping for the
specified key. |
boolean |
containsValue(Object value)
Return true if the map maps one or more keys to the specified value. |
Set |
entrySet()
Returns a set view of the mappings contained in this map. |
Object |
get(int index)
Returns the value which is stored at the specified sequential position in the map. |
Object |
get(Object key)
Returns the value to which this map maps the specified key. |
Object |
getKey(int index)
Returns the key which is stored at the specified sequential position in the map. |
int |
indexOf(Object key)
Index of the entry with the given key. |
Object |
put(Object key,
Object value)
Associates the specified value with the specified key in this map. |
Object |
remove(Object key)
Removes the mapping for this key from this map if present. |
int |
size()
Return the number of entries in the map. |
Object |
update(Object key,
Object value)
Update an existing key-value pair. |
Methods inherited from class java.util.AbstractMap |
clone, equals, hashCode, isEmpty, keySet, putAll, toString, values |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
equals, hashCode, isEmpty, keySet, putAll, values |
Field Detail |
public static final String versionId
Constructor Detail |
public SequentialMap()
Creates an empty SequentialMap
.
Method Detail |
public int size()
size
in interface Map
public int indexOf(Object key)
Index of the entry with the given key. key
may be null.
Requires time linear in the size of the map.
key
- the key to find.
key or -1 if no such entry
exists.
public boolean containsValue(Object value)
Return true if the map maps one or more keys to the specified
value. More formally, returns true if and only if this map contains at
least one mapping to a value v
such that
(value==null ? v==null : value.equals(v))
.
Requires time linear in the size of the map
containsValue
in interface Map
value
- value whose presence in this map is to be tested.
true
if this map maps one or more keys to the
specified value.public boolean containsKey(Object key)
Returns true
if this map contains a mapping for the
specified key.
Requires time linear in the size of the map.
containsKey
in interface Map
key
- key whose presence in this map is to be tested.
true
if this map contains a mapping for the
specified key.public Object get(Object key)
Returns the value to which this map maps the specified key. Returns
null
if the map contains no mapping for this key. A
return value of null
does not necessarily indicate that
the map contains no mapping for the key; it's also possible that the
map explicitly maps the key to null
. The
containsKey
operation may be used to distinguish these
two cases.
Requires time linear in the size of the map.
get
in interface Map
key
- key whose associated value is to be returned.
null
if the map contains no mapping for this key.public Object get(int index)
Returns the value which is stored at the specified sequential position in the map. May throw an IndexOutOfBoundsException if (index < 0 || index >= size()).
Requires constant time.
index
- The index of the element to return.
public Object getKey(int index)
Returns the key which is stored at the specified sequential position in the map. May throw an IndexOutOfBoundsException if (index < 0 || index >= size()).
Requires constant time.
index
- The index of the element to return.
public Object put(Object key, Object value)
key
already exists, it is removed first. To change the
value of an existing key-value pair without changing the position of
the key
, use update
.
Requires time linear in the size of the map
put
in interface Map
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.
update
public Object update(Object key, Object value)
Update an existing key-value pair. If an entry with key
key
already exists, it is replaced with the new
association without changing the place in which the key appears in the
sequence of keys. If no such entry exists, it is appended at the end.
Requires time linear in the size of the map.
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.
put
public Object remove(Object key)
Removes the mapping for this key from this map if present.
remove
in interface Map
key
- key whose mapping is to be removed from the map.
public void clear()
Removes all mappings from this map.
clear
in interface Map
public Set entrySet()
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.
entrySet
in interface Map
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |