Business Objects
Quark Platform Documentation
Version 1.7.0_0
Business Objects

org.openquark.cal.util
Class ArrayMap<K,V>

java.lang.Object
  extended by org.openquark.cal.util.ArrayMap<K,V>
All Implemented Interfaces:
Map<K,V>

public final class ArrayMap<K,V>
extends Object
implements Map<K,V>

A map whose elements are ordered by the insertion order of elements in the map. This class allows both O(1) map lookup (like HashMap) and O(1) indexing (like ArrayList).

The SequencedHashMap at http://jakarta.apache.org/commons/collections/ provides a similar interface but doesn't support O(1) integer indexing.

The LinkedHashMap of jdk 1.4 is almost as good, but we want to be able to conveniently define a type safe iterator and we don't need to be able to remove elements from the map, so that this class does the job.

Creation date (Nov 6, 2002).

Author:
Bo Ilic

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
ArrayMap()
           
 
Method Summary
 void clear()
          
 boolean containsKey(Object key)
          
 boolean containsValue(Object value)
          
 Set<Map.Entry<K,V>> entrySet()
          
 V get(Object key)
          
 K getNthKey(int index)
           
 V getNthValue(int index)
           
 boolean isEmpty()
          
 Set<K> keySet()
          
 V put(K key, V value)
          Adds the (key, value) pair to the map, provided that the map doesn't already contain the key.
 void putAll(Map<? extends K,? extends V> t)
          
 V remove(Object key)
          
 int size()
          
 String toString()
           
 Collection<V> values()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

ArrayMap

public ArrayMap()
Method Detail

put

public V put(K key,
             V value)
Adds the (key, value) pair to the map, provided that the map doesn't already contain the key.

Specified by:
put in interface Map<K,V>
Parameters:
key -
value -
Returns:
Object null (will throw and IllegalArgumentException if the key already exists in the map.
Throws:
NullPointerException - if either argument is null.

get

public V get(Object key)

Specified by:
get in interface Map<K,V>

getNthKey

public K getNthKey(int index)

getNthValue

public V getNthValue(int index)

size

public int size()

Specified by:
size in interface Map<K,V>

containsKey

public boolean containsKey(Object key)

Specified by:
containsKey in interface Map<K,V>

toString

public String toString()
Overrides:
toString in class Object

clear

public void clear()

Specified by:
clear in interface Map<K,V>

isEmpty

public boolean isEmpty()

Specified by:
isEmpty in interface Map<K,V>

containsValue

public boolean containsValue(Object value)

Specified by:
containsValue in interface Map<K,V>

values

public Collection<V> values()

Specified by:
values in interface Map<K,V>

putAll

public void putAll(Map<? extends K,? extends V> t)

Specified by:
putAll in interface Map<K,V>

entrySet

public Set<Map.Entry<K,V>> entrySet()

Specified by:
entrySet in interface Map<K,V>

keySet

public Set<K> keySet()

Specified by:
keySet in interface Map<K,V>

remove

public V remove(Object key)

Specified by:
remove in interface Map<K,V>

Business Objects
Quark Platform Documentation
Version 1.7.0_0
Business Objects

Copyright © 2007 Business Objects. All rights reserved.