|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.alee.utils.collection.ValuesTable<K,V>
@XStreamConverter(value=ValuesTableConverter.class) public class ValuesTable<K,V>
This class allows you to create key-value table from which you can either request a key by value or a value by key. Both key and value should be unique and adding same key or value will replace existing one in the lists.
Field Summary | |
---|---|
protected java.util.List<K> |
keys
Keys list. |
protected java.util.Map<V,K> |
keysByValues
Keys by values map. |
protected java.util.List<V> |
values
Values list. |
protected java.util.Map<K,V> |
valuesByKeys
Values by keys map. |
Constructor Summary | |
---|---|
ValuesTable()
Constructs an empty ValuesTable with initial capacity of ten. |
|
ValuesTable(int initialCapacity)
Constructs an empty ValuesTable with the specified initial capacity. |
Method Summary | |
---|---|
void |
add(int index,
K key,
V value)
Adds a single entry (key-value pair) into this ValuesTable at the specified index. |
void |
add(K key,
V value)
Adds a single entry (key-value pair) into this ValuesTable. |
void |
addAll(java.util.Map<K,V> data)
Adds all Map entries into this ValuesTable. |
void |
addAll(ValuesTable<K,V> data)
Adds all ValuesTable entries into this ValuesTable. |
boolean |
contains(K key)
Returns whether this ValuesTable contains entry with specified key or not. |
boolean |
containsKey(K key)
Returns whether this ValuesTable contains entry with specified key or not. |
boolean |
containsValue(V value)
Returns whether this ValuesTable contains entry with specified value or not. |
V |
get(int index)
Returns entry value at the specified index. |
V |
get(K key)
Returns value from entry with specified key. |
K |
getKey(int index)
Returns entry key at the specified index. |
K |
getKey(V value)
Returns key from entry with specified value. |
java.util.List<K> |
getKeys()
Returns copy of keys list. |
V |
getValue(int index)
Returns entry value at the specified index. |
V |
getValue(K key)
Returns value from entry with specified key. |
java.util.List<V> |
getValues()
Returns copy of values list. |
int |
indexOf(K key)
Returns index of entry with the specified key. |
int |
indexOfKey(K key)
Returns index of entry with the specified key. |
int |
indexOfValue(V value)
Returns index of entry with the specified value. |
protected java.lang.String |
outOfBoundsMsg(int index)
Returns a message text for IndexOutOfBoundsException exception. |
void |
put(int index,
K key,
V value)
Adds a single entry (key-value pair) into this ValuesTable at the specified index. |
void |
put(K key,
V value)
Adds a single entry (key-value pair) into this ValuesTable. |
void |
putAll(java.util.Map<K,V> data)
Adds all Map entries into this ValuesTable. |
void |
putAll(ValuesTable<K,V> data)
Adds all ValuesTable entries into this ValuesTable. |
void |
remove(int index)
Removes entry at the specified index. |
void |
remove(K key)
Removes entry with the specified key. |
void |
removeByKey(K key)
Removes entry with the specified key. |
void |
removeByValue(V value)
Removes entry with the specified value. |
protected void |
removeExistingEntry(int index)
Removes entry at the specified index. |
int |
size()
Returns ValuesTable size. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.List<K> keys
protected java.util.List<V> values
protected java.util.Map<K,V> valuesByKeys
protected java.util.Map<V,K> keysByValues
Constructor Detail |
---|
public ValuesTable()
public ValuesTable(int initialCapacity)
initialCapacity
- initial table capacityMethod Detail |
---|
public java.util.List<K> getKeys()
public java.util.List<V> getValues()
public void addAll(java.util.Map<K,V> data)
data
- Map with entriespublic void putAll(java.util.Map<K,V> data)
data
- Map with entriespublic void addAll(ValuesTable<K,V> data)
data
- ValuesTable with entriespublic void putAll(ValuesTable<K,V> data)
data
- ValuesTable with entriespublic void add(K key, V value)
key
- entry keyvalue
- entry valuepublic void put(K key, V value)
key
- entry keyvalue
- entry valuepublic void add(int index, K key, V value)
index
- entry indexkey
- entry keyvalue
- entry valuepublic void put(int index, K key, V value)
index
- entry indexkey
- entry keyvalue
- entry valuepublic void remove(K key)
key
- entry keypublic void removeByKey(K key)
key
- entry keypublic void removeByValue(V value)
value
- entry valuepublic void remove(int index)
index
- entry indexprotected void removeExistingEntry(int index)
index
- entry indexpublic V get(int index)
index
- entry index
public V getValue(int index)
index
- entry index
public K getKey(int index)
index
- entry index
public V get(K key)
key
- entry key
public V getValue(K key)
key
- entry key
public K getKey(V value)
value
- entry value
public boolean contains(K key)
key
- entry key
public boolean containsKey(K key)
key
- entry key
public boolean containsValue(V value)
value
- entry value
public int indexOf(K key)
key
- entry key
public int indexOfKey(K key)
key
- entry key
public int indexOfValue(V value)
value
- entry value
public int size()
protected java.lang.String outOfBoundsMsg(int index)
index
- index that is out of bounds
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |