|
|
|
@ -26,6 +26,8 @@ |
|
|
|
|
|
|
|
package jdd; |
|
|
|
|
|
|
|
import java.util.Collections; |
|
|
|
import java.util.Comparator; |
|
|
|
import java.util.Iterator; |
|
|
|
import java.util.Vector; |
|
|
|
|
|
|
|
@ -133,6 +135,29 @@ public class JDDVars implements Iterable<JDDNode> |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Copy JDDNodes from another JDDVars, merge into the existing variables, |
|
|
|
* sorting by the variable indices. Afterwards, this JDDVars container |
|
|
|
* is fully sorted by variable indices, i.e., the existing variables are |
|
|
|
* sorted as well. |
|
|
|
* @param ddv the new variables |
|
|
|
*/ |
|
|
|
public void mergeVarsFrom(JDDVars ddv) { |
|
|
|
copyVarsFrom(ddv); |
|
|
|
sortByIndex(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Remove variable v from container. Does not decrease the refcount. |
|
|
|
*/ |
|
|
|
public void removeVar(JDDNode v) |
|
|
|
{ |
|
|
|
vars.remove(v); |
|
|
|
if (arrayBuilt) DDV_FreeArray(array); |
|
|
|
arrayBuilt = false; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Removes the JDDNodes contained in ddv from this JDDVars container. |
|
|
|
* Does not decrease the refcount! |
|
|
|
@ -346,6 +371,21 @@ public class JDDVars implements Iterable<JDDNode> |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
/** Sort the variables in this container by their variable index. */ |
|
|
|
public void sortByIndex() |
|
|
|
{ |
|
|
|
if (arrayBuilt) DDV_FreeArray(array); |
|
|
|
arrayBuilt = false; |
|
|
|
|
|
|
|
Collections.sort(vars, new Comparator<JDDNode>() { |
|
|
|
@Override |
|
|
|
public int compare(JDDNode a, JDDNode b) |
|
|
|
{ |
|
|
|
return new Integer(a.getIndex()).compareTo(b.getIndex()); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//------------------------------------------------------------------------------ |