org.norther.tammi.acorn.util
Interface OrderedMap<K,V>

Type Parameters:
K - the type of keys maintained by this map.
V - the type of mapped values.
All Superinterfaces:
ConcurrentMap<K,V>, Map<K,V>
All Known Implementing Classes:
Configuration, ModifiableOrderedMap, OrderedHashMap, UnmodifiableOrderedMap

public interface OrderedMap<K,V>
extends ConcurrentMap<K,V>

An extension to ConcurrentMap providing key and entry sets and a value collection, as well as key, entry and value lists, maintaining the definition order of map entries.

Version:
$Id: OrderedMap.java,v 1.13 2009/10/21 15:05:07 cvsimp Exp $
Author:
Ilkka Priha

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Method Summary
 boolean add(K key, V value)
          Associates the specified value with the specified key at the end of this map if not already mapped.
 boolean addAt(int index, K key, V value)
          Associates the specified value with the specified key at the specified index in this map if not already mapped.
 List<Map.Entry<K,V>> entryList()
          Returns an ordered list of mapped entries.
 OrderedSet<Map.Entry<K,V>> entrySet()
          Returns an ordered set of mapped entries.
 V get(int index)
          Gets the indexed value in this map.
 Map.Entry<K,V> getEntryAt(int index)
          Gets the indexed entry in this map.
 K getKeyAt(int index)
          Gets the indexed key in this map.
 int indexOfKey(Object key)
          Returns the index of the specified key, or -1 if not found.
 boolean isModifiable()
          Checks whether this map is modifiable.
 List<K> keyList()
          Returns an ordered list of mapped keys.
 OrderedSet<K> keySet()
          Returns an ordered set of mapped keys.
 V put(int index, K key, V value)
          Associates the specified value with the specified key at the specified index in this map.
 void putAll(int index, Map<? extends K,? extends V> map)
          Copies all of the mappings from the specified map to this map starting from the specified index.
 V putIfAbsent(int index, K key, V value)
          Associates the specified value with the specified key at the specified index in this map if not already mapped.
 Map.Entry<K,V> removeAt(int index)
          Removes the indexed element in this map.
 V replace(int index, V value)
          Replaces the indexed element in this map.
 Map.Entry<K,V> set(int index, K key, V value)
          Associates the specified value with the specified key at the specified index in this map.
 Map.Entry<K,V> shift(int index, K key, V value)
          Associates the specified value with the specified key at the specified index in this map if already mapped.
 List<V> valueList()
          Returns an ordered list of mapped values.
 Collection<V> values()
          Returns an ordered collection of mapped values.
 
Methods inherited from interface java.util.concurrent.ConcurrentMap
putIfAbsent, remove, replace, replace
 
Methods inherited from interface java.util.Map
clear, containsKey, containsValue, equals, get, hashCode, isEmpty, put, putAll, remove, size
 

Method Detail

isModifiable

boolean isModifiable()
Checks whether this map is modifiable.

Returns:
true for a modifiable map, false otherwise.

indexOfKey

int indexOfKey(Object key)
Returns the index of the specified key, or -1 if not found.

Parameters:
key - the key.
Returns:
the index of the key.

getKeyAt

K getKeyAt(int index)
Gets the indexed key in this map.

Parameters:
index - the index.
Returns:
the indexed value.
Throws:
IndexOutOfBoundsException - if the index is out of range.

get

V get(int index)
Gets the indexed value in this map.

Parameters:
index - the index.
Returns:
the indexed value.
Throws:
IndexOutOfBoundsException - if the index is out of range.

getEntryAt

Map.Entry<K,V> getEntryAt(int index)
Gets the indexed entry in this map.

Parameters:
index - the index.
Returns:
the indexed entry.
Throws:
IndexOutOfBoundsException - if the index is out of range.

put

V put(int index,
      K key,
      V value)
Associates the specified value with the specified key at the specified index in this map. An existing key is not moved.

Parameters:
index - the index.
key - the key with which the specified value is to be associated.
value - the value to be associated with the specified key.
Returns:
the previous value associated with the specified key.
Throws:
IndexOutOfBoundsException - if the index is out of range.

putIfAbsent

V putIfAbsent(int index,
              K key,
              V value)
Associates the specified value with the specified key at the specified index in this map if not already mapped.

Parameters:
index - the index.
key - the key with which the specified value is to be associated.
value - the value to be associated with the specified key.
Returns:
the previous value associated with the specified key.

putAll

void putAll(int index,
            Map<? extends K,? extends V> map)
Copies all of the mappings from the specified map to this map starting from the specified index.

Parameters:
index - the index.
map - mappings to be stored in this map

set

Map.Entry<K,V> set(int index,
                   K key,
                   V value)
Associates the specified value with the specified key at the specified index in this map. An existing key is moved to the indexed position whereas a new one replaces the previous association at the same index.

Parameters:
index - the index.
key - the key with which the specified value is to be associated.
value - the value to be associated with the specified key.
Returns:
the removed entry at the specified index or null.
Throws:
IndexOutOfBoundsException - if the index is out of range.

shift

Map.Entry<K,V> shift(int index,
                     K key,
                     V value)
Associates the specified value with the specified key at the specified index in this map if already mapped. The previous association at the same index is shifted to the original index of the specified key.

Parameters:
index - the index.
key - the key with which the specified value is to be associated.
value - the value to be associated with the specified key.
Returns:
the shifted entry at the specified index or null.
Throws:
IndexOutOfBoundsException - if the index is out of range.

add

boolean add(K key,
            V value)
Associates the specified value with the specified key at the end of this map if not already mapped.

Parameters:
key - the key with which the specified value is to be associated.
value - the value to be associated with the specified key.
Returns:
true if added, false otherwise.

addAt

boolean addAt(int index,
              K key,
              V value)
Associates the specified value with the specified key at the specified index in this map if not already mapped.

Parameters:
index - the index.
key - the key with which the specified value is to be associated.
value - the value to be associated with the specified key.
Returns:
true if added, false otherwise.

replace

V replace(int index,
          V value)
Replaces the indexed element in this map.

Parameters:
index - the index.
value - the new value.
Returns:
the replaced value.
Throws:
IndexOutOfBoundsException - if the index is out of range.

removeAt

Map.Entry<K,V> removeAt(int index)
Removes the indexed element in this map.

Parameters:
index - the index.
Returns:
the removed entry.
Throws:
IndexOutOfBoundsException - if the index is out of range.

keySet

OrderedSet<K> keySet()
Returns an ordered set of mapped keys.

Specified by:
keySet in interface Map<K,V>
Returns:
a set of keys.

values

Collection<V> values()
Returns an ordered collection of mapped values.

Specified by:
values in interface Map<K,V>
Returns:
a collection of values.

entrySet

OrderedSet<Map.Entry<K,V>> entrySet()
Returns an ordered set of mapped entries.

Specified by:
entrySet in interface Map<K,V>
Returns:
a set of entries.

keyList

List<K> keyList()
Returns an ordered list of mapped keys.

Returns:
a list of keys.

valueList

List<V> valueList()
Returns an ordered list of mapped values.

Returns:
a list of values.

entryList

List<Map.Entry<K,V>> entryList()
Returns an ordered list of mapped entries.

Returns:
a list of entries.


Copyright © 2004 The Norther Organization. All rights reserved.