public interface SimpleList<E>
List
. Subclasses exist that permit
efficient appending and concatenation:
SimpleArrayList
: a typical list is stored as an array list.
ListOfLists
: a list that only stores pointers to its constituent sub-lists.
OneMoreElementList
: stores a SimpleList plus one additional final element.
IMPLEMENTATION NOTE
Randoop's main generator (ForwardGenerator
)
creates new sequences by concatenating existing sequences and appending a statement at the end.
When profiling Randoop, we observed that naive concatenation took up a large portion of the
tool's running time, and the component set (i.e. the set of stored sequences used to create more
sequences) quickly exhausted the memory available.
To improve memory and time efficiency, we now do concatenation differently.
When concatenating N Sequences to create a new sequence, we store the concatenated sequence statements in a ListofLists, which takes space (and creation time) proportional to N, not to the length of the new sequence.
When extending a Sequence with a new statement, we store the old sequence's statements plus
the new statement in a OneMoreElementList
, which takes up only 2 references in memory
(and constant creation time).
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.
|
int size()
boolean isEmpty()
E get(int index)
index
- the position for the elementSimpleList<E> getSublist(int index)
The result is always an existing SimpleList, the smallest one that contains the index.
Currently, it is always a SimpleArrayList
.
index
- the index into this listjava.util.List<E> toJDKList()
List
for this list