randoop
Class SequenceCollection

Object
  extended by SequenceCollection

public class SequenceCollection
extends Object

A collection of sequences that makes its efficient to ask for all the sequences that create a value of a given type.

RANDOOP IMPLEMENTATION NOTE.

When creating new sequences, Randoop often needs to search for all the previously-generated sequences that create one or more values of a given type. Since this set can contain thousands of sequences, finding these sequences can can be time-consuming and a bottleneck in generation (as we discovered during profiling).

This class makes the above search faster by maintanining two data structures:

To find all the sequences that create values of a given type, Randoop first uses the SubTypeSet to find the set S of feasible subtypes in set of sequences, and returns the range of S in the sequence map.


Field Summary
Modifier and Type Field and Description
 int numActivesequences
           
 
Constructor Summary
Constructor and Description
SequenceCollection()
          Create a new, empty collection.
SequenceCollection(Collection<Sequence> initialSequences)
          Create a new collection and adds the given initial sequences.
 
Method Summary
Modifier and Type Method and Description
 void add(Sequence sequence)
          Add a sequence to this collection.
 void addAll(Collection<Sequence> col)
           
 void addAll(SequenceCollection components)
           
 void clear()
          Removes all sequences from this collection.
 Set<Sequence> getAllSequences()
           
 Set<StatementKind> getAllStatements()
           
 SimpleList<Sequence> getSequencesForType(Class<?> clazz, boolean exactMatch)
          Searches through the set of active sequences to find all sequences whose types match with the parameter type.
 Set<Class<?>> getTypesThatHaveSequences()
           
 boolean hasSequences(Class<?> targetClass, Reflection.Match match)
           
 int numTypes()
           
 int size()
           
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

numActivesequences

public int numActivesequences
Constructor Detail

SequenceCollection

public SequenceCollection()
Create a new, empty collection.


SequenceCollection

public SequenceCollection(Collection<Sequence> initialSequences)
Create a new collection and adds the given initial sequences.

Method Detail

numTypes

public int numTypes()

size

public int size()

clear

public void clear()
Removes all sequences from this collection.


addAll

public void addAll(Collection<Sequence> col)

addAll

public void addAll(SequenceCollection components)

add

public void add(Sequence sequence)
Add a sequence to this collection. This method takes into account the active indices in the sequence. If sequence[i] creates a values of type T, and sequence[i].isActive==true, then the sequence is seen as creating a useful value at index i. More precisely, the method/constructor at that index is said to produce a useful value (and if the user later queries for all sequences that create a T, the sequence will be in the collection returned by the query). How a value is deemed useful or not is left up to the client.


getSequencesForType

public SimpleList<Sequence> getSequencesForType(Class<?> clazz,
                                                boolean exactMatch)
Searches through the set of active sequences to find all sequences whose types match with the parameter type.

Parameters:
clazz - - the type desired for the sequences being sought
Returns:
list of sequence objects that are of typp 'type' and abide by the constraints defined by nullOk.

getTypesThatHaveSequences

public Set<Class<?>> getTypesThatHaveSequences()

hasSequences

public boolean hasSequences(Class<?> targetClass,
                            Reflection.Match match)

getAllSequences

public Set<Sequence> getAllSequences()

getAllStatements

public Set<StatementKind> getAllStatements()