|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.AbstractCollection<E> java.util.AbstractList<E> java.util.ArrayList<TableList.Fields> org.knowceans.util.TableList org.knowceans.util.KeyTableList
public class KeyTableList
KeyTableList is a table list that allows to define indices on fields called keys. Use this implementation if frequent lookups are necessary without reordering the list and using binarySearch. This implementation is thought to provide quick access to larger table lists. It also allows to search for elements using wildcards and regular expressions.
Important note: The class is designed to grow the list, add key maps and then possibly add elements and find elements, but manipulation of the elements via the get method result in undefined behaviour because the key maps become inconsistent. Use the set method and replace complete list elements (fields). Further, removal and manipulation via set are expensive because of the reverse lookup in the key lists.
TODO: Check why iteration is actually faster than map.
TODO: To retain consistent behaviour, implement a transaction that stores the old values to look them up later in the maps and replace them with new values.
This class re-enacts much of a table in a relational (or object-relational) database.
TODO: merge with JoSQL to increase scalability.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.knowceans.util.TableList |
---|
TableList.FieldBetween, TableList.FieldComparator, TableList.FieldEquals, TableList.FieldGreaterThan, TableList.FieldLessThan, TableList.FieldRegexFind, TableList.Fields, TableList.Filter, TableList.SingleFieldFilter |
Constructor Summary | |
---|---|
KeyTableList()
|
|
KeyTableList(int initialCapacity)
|
|
KeyTableList(java.util.List<java.lang.String> fields)
|
|
KeyTableList(java.util.List<TableList.Fields> list,
java.util.List<java.lang.String> fields)
|
|
KeyTableList(TableList list)
|
Method Summary | |
---|---|
void |
add(int index,
TableList.Fields element)
|
boolean |
add(TableList.Fields f)
|
boolean |
addAll(java.util.Collection<? extends TableList.Fields> c)
|
boolean |
addAll(int index,
java.util.Collection<? extends TableList.Fields> c)
|
boolean |
contains(java.lang.String field,
java.lang.Object elem)
Checks whether the element is contained in this list, based on the equals method. |
boolean |
containsAll(java.lang.String field,
java.util.Collection<?> c)
Checks whether all of the elements of c are contained in the field within the list. |
int |
indexOf(java.lang.String field,
java.lang.Object elem)
Finds the first index of the list element with elem as key field. |
int[] |
indicesOf(java.lang.String field,
java.lang.Object elem)
Finds all indices of the list elements with elem as key field. |
TableList |
indicesOfRegex(java.lang.String keyfield,
java.lang.String regex)
Find all rows that match the string field as a regular expression. |
int |
lastIndexOf(java.lang.String field,
java.lang.Object elem)
Finds the last index of the list element with elem as key field. |
static void |
main(java.lang.String[] args)
|
TableList.Fields |
remove(int index)
|
boolean |
removeAll(java.util.Collection<?> c)
|
TableList.Fields |
set(int index,
TableList.Fields element)
Set the fields at the index and updates the keys. |
void |
set(java.lang.String field,
int index,
java.lang.Object value)
Set the field at the index with the value, updating the corresponding key if necessary. |
void |
setAsKey(java.lang.String field)
Adds an existing field to the table list. |
Methods inherited from class org.knowceans.util.TableList |
---|
addIndexList, addIndexList, addList, addMap, binarySearch, binarySearch, filter, get, get, getField, getField, getFields, getList, getList, getMap, getSubList, indexOf, indicesOf, lastIndexOf, load, removeList, save, set, sort, sort, split, toArray |
Methods inherited from class java.util.ArrayList |
---|
clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, size, toArray, toArray, trimToSize |
Methods inherited from class java.util.AbstractList |
---|
equals, hashCode, iterator, listIterator, listIterator, subList |
Methods inherited from class java.util.AbstractCollection |
---|
containsAll, retainAll, toString |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.List |
---|
containsAll, equals, hashCode, iterator, listIterator, listIterator, retainAll, subList |
Constructor Detail |
---|
public KeyTableList()
public KeyTableList(int initialCapacity)
initialCapacity
- public KeyTableList(java.util.List<TableList.Fields> list, java.util.List<java.lang.String> fields)
list
- fields
- public KeyTableList(java.util.List<java.lang.String> fields)
fields
- public KeyTableList(TableList list)
list
- Method Detail |
---|
public static void main(java.lang.String[] args)
public void setAsKey(java.lang.String field)
field
- public boolean add(TableList.Fields f)
add
in interface java.util.Collection<TableList.Fields>
add
in interface java.util.List<TableList.Fields>
add
in class java.util.ArrayList<TableList.Fields>
public void add(int index, TableList.Fields element)
add
in interface java.util.List<TableList.Fields>
add
in class java.util.ArrayList<TableList.Fields>
public boolean addAll(java.util.Collection<? extends TableList.Fields> c)
addAll
in interface java.util.Collection<TableList.Fields>
addAll
in interface java.util.List<TableList.Fields>
addAll
in class java.util.ArrayList<TableList.Fields>
public boolean addAll(int index, java.util.Collection<? extends TableList.Fields> c)
addAll
in interface java.util.List<TableList.Fields>
addAll
in class java.util.ArrayList<TableList.Fields>
public boolean contains(java.lang.String field, java.lang.Object elem)
field
- elem
-
public boolean containsAll(java.lang.String field, java.util.Collection<?> c)
field
- c
-
public int indexOf(java.lang.String field, java.lang.Object elem)
indexOf
in class TableList
field
- elem
-
public int lastIndexOf(java.lang.String field, java.lang.Object elem)
lastIndexOf
in class TableList
field
- elem
-
public int[] indicesOf(java.lang.String field, java.lang.Object elem)
indicesOf
in class TableList
field
- elem
-
public TableList indicesOfRegex(java.lang.String keyfield, java.lang.String regex)
keyfield
- regex
-
public TableList.Fields remove(int index)
remove
in interface java.util.List<TableList.Fields>
remove
in class java.util.ArrayList<TableList.Fields>
public boolean removeAll(java.util.Collection<?> c)
removeAll
in interface java.util.Collection<TableList.Fields>
removeAll
in interface java.util.List<TableList.Fields>
removeAll
in class java.util.AbstractCollection<TableList.Fields>
public TableList.Fields set(int index, TableList.Fields element)
set
in interface java.util.List<TableList.Fields>
set
in class java.util.ArrayList<TableList.Fields>
index
- element
-
public void set(java.lang.String field, int index, java.lang.Object value)
set
in class TableList
field
- index
- value
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |