Class OrderedTwoWayTable
java.lang.Object
com.sun.javatest.util.OrderedTwoWayTable
A map-like structure which has two side-by-side ordered sets of Objects in pairs.
This is basically a map structure except that it is always ordered and has a less
strict an idea of key and value. The terms key and value are still used to
differentiate data from the two sets. The primary advantage to using this class
is that you can do lookups either by key or value, in case where translation in
both directions is necessary.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected intGet the index of the target in the table.getKeyAt(int index) Get the key at the given index.intgetKeyIndex(Object key) Get the position of the key within the table.intgetSize()Get the number of pairs in the table.getValueAt(int index) Get the value at the given index.intgetValueIndex(Object value) Get the position of a value within the table.voidPut an object in the table.voidremove(int index) Remove the object at a specified index.
-
Constructor Details
-
OrderedTwoWayTable
public OrderedTwoWayTable()
-
-
Method Details
-
put
-
getKeyIndex
Get the position of the key within the table.- Parameters:
key- the key whose position is required- Returns:
- the position of the key within the table, or -1 if not found
-
getValueIndex
Get the position of a value within the table.- Parameters:
value- the value whose position is required- Returns:
- the position of the value within the table, or -1 if not found
-
getValueAt
Get the value at the given index.- Parameters:
index- the index of the required value- Returns:
- the value at the given index, or null if not found or index out of bounds.
-
getKeyAt
Get the key at the given index.- Parameters:
index- the index of the given key- Returns:
- the value at the given index, null if not found or index out of bounds.
-
getSize
public int getSize()Get the number of pairs in the table.- Returns:
- the numbver of pairs on the table
-
remove
public void remove(int index) Remove the object at a specified index.- Parameters:
index- the index of the entry to be removed.
-
findIndex
-