public class SequenceCollection
extends java.lang.Object
ComponentManager
.
To find all the sequences that create values of a given type, Randoop first uses the SubTypeSet
to find the set T
of feasible subtypes, and returns the range of T
(that is, all the sequences mapped to by any t∈T) in the sequence map.
Modifier and Type | Field and Description |
---|---|
private int |
sequenceCount
Number of sequences in the collection: sum of sizes of all values in sequenceMap.
|
private java.util.Map<Type,SimpleArrayList<Sequence>> |
sequenceMap
For each type, all the sequences that produce one or more values of exactly the given type.
|
private java.util.Set<Type> |
typesAndSupertypes
A set of all the types that can be created with the sequences in this, and all their
supertypes.
|
private SubTypeSet |
typeSet
A set of all the types that can be created with the sequences in this.
|
Constructor and Description |
---|
SequenceCollection()
Create a new, empty collection.
|
SequenceCollection(java.util.Collection<Sequence> initialSequences)
Create a new collection and adds the given initial sequences.
|
Modifier and Type | Method and Description |
---|---|
void |
add(Sequence sequence)
Add a sequence to this collection.
|
void |
addAll(java.util.Collection<Sequence> col)
All all the given sequences to this collection.
|
void |
addAll(SequenceCollection components)
Add all the given sequences to this collection.
|
private void |
checkRep()
Checks the representation invariant.
|
void |
clear()
Removes all sequences from this collection.
|
java.util.Set<Sequence> |
getAllSequences()
Returns the set of all sequences in this collection.
|
SimpleList<Sequence> |
getSequencesForType(Type type,
boolean exactMatch,
boolean onlyReceivers)
Searches through the set of active sequences to find all sequences whose types match with the
parameter type.
|
TypeInstantiator |
getTypeInstantiator() |
void |
log() |
int |
size() |
private void |
updateCompatibleMap(Sequence sequence,
Type type)
Add the entry (type, sequence) to
sequenceMap . |
private java.util.Map<Type,SimpleArrayList<Sequence>> sequenceMap
private SubTypeSet typeSet
sequenceMap.keySet()
, but provides additional operations.private java.util.Set<Type> typesAndSupertypes
typeSet
.private int sequenceCount
public SequenceCollection()
public SequenceCollection(java.util.Collection<Sequence> initialSequences)
initialSequences
- the initial collection of sequencesprivate void checkRep(@UnknownInitialization(value=SequenceCollection.class) SequenceCollection this)
public int size()
public void clear()
public void addAll(@UnknownInitialization(value=SequenceCollection.class) SequenceCollection this, java.util.Collection<Sequence> col)
col
- the sequences to addpublic void addAll(@UnknownInitialization(value=SequenceCollection.class) SequenceCollection this, SequenceCollection components)
components
- the sequences to addpublic void add(@UnknownInitialization(value=SequenceCollection.class) SequenceCollection this, Sequence sequence)
Note that this takes into consideration only the assigned value for each statement. If a statement might side-effect some variable V, then V is considered as an output from the statement that declares/creates V, not the one that side-effects V.
(An alternative would be to only use outputs from the last statement, and include its inputs as well. That alternative is not implemented. It would probably be faster, but it would not handle the case of a method side-effecting a variable that that was not explicitly passed to it. That case probably isn't important/common.)
sequence
- the sequence to add to this collectionprivate void updateCompatibleMap(Sequence sequence, Type type)
sequenceMap
.sequence
- the sequencetype
- the Type
public SimpleList<Sequence> getSequencesForType(Type type, boolean exactMatch, boolean onlyReceivers)
If exactMatch==true returns only sequences that declare values of the exact class specified; if exactMatch==false returns sequences declaring values of cls or any other class that can be used as a cls (i.e. a subclass of cls).
type
- the type desired for the sequences being soughtexactMatch
- the flag to indicate whether an exact type match is requiredonlyReceivers
- if true, only return sequences that are appropriate to use as a method
call receiverpublic java.util.Set<Sequence> getAllSequences()
public TypeInstantiator getTypeInstantiator()
public void log()