java.lang.Object
dev.civl.mc.util.IF.SeqSet
A
SeqSet represents a set of sequences of nonnegative integers. By
sequence, we mean finite sequence of integers. Only certain sets are
representable. If p and q are sequences, write pinvalid input: '<'=q if p is a prefix of q.
(This includes the case p=q.) If p is a sequence, let [p] = {q|pinvalid input: '<'=q}. A
SeqSet represents a finite union of sets of the form [p]. If pinvalid input: '<'=q
then [p] contains [q], so any SeqSet S can be represented as a finite union
of sets of the form [p] where p is a minimal element of S.
If () is the empty sequence then [()] consists of all sequences. It is represented by the SeqSet {()}.
{(1,2),(1,3,4),(2)} is a SeqSet.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) classA node in the tree representation. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(int... seq) Adds the set represented by the given sequence to this set.booleanAdds everything in the given set to this set.voidclear()Makes this set empty.clone()booleancontains(int... seq) Does this set contain the set [s] of sequences which extend a given sequence s?booleancontainsAll(SeqSet that) Does this set contain the given set?booleanAre this set and the given set disjoint?booleanDo this set and the given set represent the same set of sequences?LinkedList<int[]> intersectionWith(SeqSet that) booleanisEmpty()voidmakeFull()Makes this the full set (consisting of all tuples).toString()
-
Constructor Details
-
SeqSet
public SeqSet()Creates new empty set. The root node will be created but will be inactive.
-
-
Method Details
-
isEmpty
public boolean isEmpty() -
add
public boolean add(int... seq) Adds the set represented by the given sequence to this set. No part of the given sequence object will be shared with this set.- Parameters:
seq- a non-null (but possibly empty) sequence of nonnegative integers- Returns:
trueif this operation resulted in a change to this set
-
getLeaves
-
toString
-
intersectionWith
-
addAll
Adds everything in the given set to this set. In the post-state, this SeqSet will represent the union of the set represented by this SeqSet in the pre-state and the set represented bythat. SeqSetthatis not modified.Perform DFS of that while walking through this in tandem with the search. Specifically:
Let u be the current node for this and v for that. If u is a leaf then backtrack. If v is leaf than prune the children of u and backtrack. Otherwise, iterate over the edges of v. For an edge on int a, see if u has an edge on a. If u does have an edge on a, proceed to the target node in both trees. If u does not have an edge on a, copy the branch starting with a from v to u.
- Parameters:
that- a non-nullSeqSet- Returns:
trueiff this operation results in a change to thisSeqSet
-
clone
-
contains
public boolean contains(int... seq) Does this set contain the set [s] of sequences which extend a given sequence s?- Parameters:
seq- a non-null (but possibly empty) sequence of nonnegative integers; note that if s is the empty sequence the [s] is the universal set consisting of all sequences- Returns:
- true iff this set contains all sequences which extend
seq(includingseqitself)
-
containsAll
Does this set contain the given set?- Parameters:
that- a non-null (but possibly empty) SeqSet- Returns:
trueiff the set of sequences represented by this SeqSet contains the set of sequences represented bythat
-
disjoint
Are this set and the given set disjoint?- Parameters:
that- a non-null SeqSet- Returns:
trueiff the two sets are disjoint
-
equals
Do this set and the given set represent the same set of sequences? -
clear
public void clear()Makes this set empty. -
makeFull
public void makeFull()Makes this the full set (consisting of all tuples).
-