public class ListOfLists<E> extends java.lang.Object implements SimpleList<E>, java.io.Serializable
This class is used for performance reasons. We want the ability to select elements collected across several lists, but we observed that creating a brand new list (i.e. via a sequence of List.addAll(..) operations can be very expensive, because it happened in a hot spot (method SequenceCollection.getSequencesThatYield).
| Modifier and Type | Field and Description |
|---|---|
private int[] |
cumulativeSize
The i-th value is the number of elements in the sublists up to the i-th one, inclusive.
|
java.util.List<SimpleList<E>> |
lists
The lists themselves.
|
private static long |
serialVersionUID |
private int |
totalelements
The size of this collection.
|
| Constructor and Description |
|---|
ListOfLists(java.util.List<SimpleList<E>> lists) |
ListOfLists(SimpleList<E>... lists)
Create a ListOfLists from ...
|
| Modifier and Type | Method and Description |
|---|---|
E |
get(int index)
Return the element at the given position of this list.
|
SimpleList<E> |
getSublist(int index)
Return a sublist of this list that contains the index.
|
boolean |
isEmpty()
Test if this list is empty.
|
int |
size()
Return the number of elements in this list.
|
java.util.List<E> |
toJDKList()
Returns a java.util.List version of this list.
|
java.lang.String |
toString() |
private static final long serialVersionUID
public final java.util.List<SimpleList<E>> lists
private int[] cumulativeSize
private int totalelements
public ListOfLists(SimpleList<E>... lists)
lists - the lists that will compose the newly-created ListOfListspublic ListOfLists(java.util.List<SimpleList<E>> lists)
public int size()
SimpleListsize in interface SimpleList<E>public boolean isEmpty()
SimpleListisEmpty in interface SimpleList<E>public E get(int index)
SimpleListget in interface SimpleList<E>index - the position for the elementpublic SimpleList<E> getSublist(int index)
SimpleListThe result is always an existing SimpleList, the smallest one that contains the index.
Currently, it is always a SimpleArrayList.
getSublist in interface SimpleList<E>index - the index into this listpublic java.util.List<E> toJDKList()
SimpleListtoJDKList in interface SimpleList<E>List for this listpublic java.lang.String toString()
toString in class java.lang.Object