public class TwoWayTokenMap extends TokenList
Two-way Token Map allows efficient key->value and value->key lookups. Also speeds up "contains"-operation.
TokenList which is an ArrayList.TokenIntMap which is an HashMap.Elements may not be inserted twice (bijection).
CAP, size| Constructor and Description |
|---|
TwoWayTokenMap() |
| Modifier and Type | Method and Description |
|---|---|
void |
add(byte[] e)
Adds an element.
|
void |
add(long e)
Adds an element.
|
void |
add(java.lang.String e)
Adds an element.
|
boolean |
contains(byte[] e)
Checks if the specified element is found in the list.
|
boolean |
contains(java.lang.String e)
Checks if the specified element is found in the list.
|
int |
delete(byte[] val)
Deletes a value.
|
int |
delete(java.lang.String val)
Deletes a value.
|
int |
getKey(byte[] val)
Gets key by value.
|
int |
getKey(java.lang.String val)
Gets key by value.
|
byte[] |
pop()
Pops the uppermost element from the stack.
|
void |
push(byte[] val)
Pushes an element onto the stack.
|
void |
set(int i,
byte[] e)
Sets an element at the specified index.
|
void |
set(int i,
java.lang.String e)
Sets an element at the specified index.
|
TokenList |
sort(boolean cs)
Sorting a TwoWayTokenMap is not implemented.
|
public void add(byte[] e)
public void add(long e)
public void add(java.lang.String e)
public void set(int i,
byte[] e)
public void set(int i,
java.lang.String e)
i - indexe - element to be setjava.lang.IllegalArgumentException - when element already existspublic byte[] pop()
TokenListpublic void push(byte[] val)
public boolean contains(byte[] e)
TokenListpublic boolean contains(java.lang.String e)
e - element to be checkedcontains(byte[])public TokenList sort(boolean cs)
public int getKey(byte[] val)
val - Value to search forpublic int getKey(java.lang.String val)
val - Value to search forpublic int delete(byte[] val)
ElementList.size() will not represent actual size any more
and TokenList.get(int) will return null values for this key afterwards!val - Value to deletepublic final int delete(java.lang.String val)
ElementList.size() will not represent actual size any more
and TokenList.get(int) will return null values for this key afterwards!val - Value to delete