Interface SimpleList<E>
-
- All Known Implementing Classes:
ListOfLists
,OneMoreElementList
,SimpleArrayList
public interface SimpleList<E>
Stores a sequence of items, much like a regularList
. 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).
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method 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.List<E>
toJDKList()
Returns a java.util.List version of this list.
-
-
-
Method Detail
-
size
int size()
Return the number of elements in this list.- Returns:
- the number of elements in this list
-
isEmpty
boolean isEmpty()
Test if this list is empty.- Returns:
- true if this list is empty, false otherwise
-
get
E get(int index)
Return the element at the given position of this list.- Parameters:
index
- the position for the element- Returns:
- the element at the index
-
getSublist
SimpleList<E> getSublist(int index)
Return a sublist of this list that contains the index. Does not necessarily contain the first element.The result is always an existing SimpleList, the smallest one that contains the index. Currently, it is always a
SimpleArrayList
.- Parameters:
index
- the index into this list- Returns:
- the sublist containing this index
-
-