|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.enough.polish.util.KeyValueList<K,V>
K - type of keys; when you use the enough-polish-client-java5.jar you can parameterize the KeyValueList, e.g. KeyValueList<Integer, String> = new KeyValueList<Integer, String>(10);V - type of values; when you use the enough-polish-client-java5.jar you can parameterize the KeyValueList, e.g. KeyValueList<Integer, String> = new KeyValueList<Integer, String>(10);public class KeyValueList<K,V>
Provides a list that may contain several duplicate keys
Copyright Enough Software 2008
| Field Summary | |
|---|---|
ArrayList<K> |
keys
|
ArrayList<V> |
values
|
| Constructor Summary | |
|---|---|
KeyValueList()
Creates an KeyValueList with the initial capacity of 10 and a growth factor of 75% |
|
KeyValueList(int initialCapacity)
Creates an KeyValueList with the given initial capacity and a growth factor of 75% |
|
KeyValueList(int initialCapacity,
int growthFactor)
Creates a new KeyValueList |
|
| Method Summary | |
|---|---|
void |
add(int index,
K key,
V value)
Inserts the given element at the defined position. |
void |
add(K key,
V value)
Stores the given key-value pair in this list. |
void |
clear()
Removes all of the elements from this list. |
boolean |
containsKey(K element)
Determines whether the given key is stored in this list. |
boolean |
containsValue(V element)
Determines whether the given value is stored in this list. |
Object[] |
getInternalKeyArray()
Retrieves the internal key array - use with care! This method allows to access stored objects without creating an intermediate array. |
Object[] |
getInternalValueArray()
Retrieves the internal value array - use with care! This method allows to access stored objects without creating an intermediate array. |
K |
getKey(int index)
Returns the key at the specified position in this list. |
V |
getValue(int index)
Returns the value at the specified position in this list. |
int |
indexOfKey(K element)
Retrieves the (first) index of the given key. |
int |
indexOfValue(V element)
Retrieves the (first) index of the given value. |
void |
read(DataInputStream in)
Restores the internal instance fields from the given input stream. |
K |
remove(int index)
Removes the key-value pair at the specified position in this list. |
boolean |
remove(K element)
Removes the given key and the corresponding value. |
K |
set(int index,
K key,
V value)
Replaces the key-value pair at the specified position in this list with the specified element. |
int |
size()
Retrieves the current size of this array list. |
void |
write(DataOutputStream out)
Stores the internal instance fields to the output stream. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public final ArrayList<K> keys
public final ArrayList<V> values
| Constructor Detail |
|---|
public KeyValueList()
public KeyValueList(int initialCapacity)
initialCapacity - the capacity of this list.
public KeyValueList(int initialCapacity,
int growthFactor)
initialCapacity - the capacity of this list.growthFactor - the factor in % for increasing the capacity
when there's not enough room in this list anymore| Method Detail |
|---|
public int size()
public boolean containsKey(K element)
element - the key which might be stored in this list
IllegalArgumentException - when the given element is nullremove(Object)public boolean containsValue(V element)
element - the value which might be stored in this list
IllegalArgumentException - when the given element is nullremove(Object)public int indexOfKey(K element)
element - the key which is part of this list.
IllegalArgumentException - when the given element is nullpublic int indexOfValue(V element)
element - the value which is part of this list.
IllegalArgumentException - when the given element is nullpublic K getKey(int index)
index - the position of the desired element.
IndexOutOfBoundsException - when the index < 0 || index >= size()public V getValue(int index)
index - the position of the desired element.
IndexOutOfBoundsException - when the index < 0 || index >= size()public K remove(int index)
index - the position of the desired element.
IndexOutOfBoundsException - when the index < 0 || index >= size()public boolean remove(K element)
element - the element which should be removed.
IllegalArgumentException - when the given element is nullcontainsKey(Object)public void clear()
public void add(K key,
V value)
key - the keyvalue - the value
IllegalArgumentException - when the given key or value is nulladd( int, Object, Object )
public void add(int index,
K key,
V value)
index - the position at which the element should be inserted,
use 0 when the element should be inserted in the front of this list.key - the keyvalue - the value
IllegalArgumentException - when the given element is null
IndexOutOfBoundsException - when the index < 0 || index >= size()
public K set(int index,
K key,
V value)
index - the position of the element, the first element has the index 0.key - the keyvalue - the value
IndexOutOfBoundsException - when the index < 0 || index >= size()public Object[] getInternalKeyArray()
public Object[] getInternalValueArray()
public void read(DataInputStream in)
throws IOException
Externalizable
read in interface Externalizablein - the input stream from which the data is loaded
IOException - when reading fails
public void write(DataOutputStream out)
throws IOException
Externalizable
write in interface Externalizableout - the output stream to which instance fields should be written
IOException - when writing fails
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||