Browse Source

JDDVars: add JavaDoc comments

git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@10428 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Joachim Klein 11 years ago
parent
commit
08b35e422a
  1. 86
      prism/src/jdd/JDDVars.java

86
prism/src/jdd/JDDVars.java

@ -28,6 +28,15 @@ package jdd;
import java.util.Vector; import java.util.Vector;
/**
* Container for MTBDD variables.
* Each variable is represented by a JDDNode (result of JDD.Var(), a projection function).
*
* It is assumed in general that each JDDNode held in a JDDVars container
* counts as a single reference and that a JDDVars object is cleared using derefAll()
* when no longer used. This will dereference all the variables contained in the JDDVars
* object.
*/
public class JDDVars public class JDDVars
{ {
private Vector<JDDNode> vars; private Vector<JDDNode> vars;
@ -49,6 +58,9 @@ public class JDDVars
} }
} }
/**
* Constructor.
*/
public JDDVars() public JDDVars()
{ {
vars = new Vector<JDDNode>(); vars = new Vector<JDDNode>();
@ -56,6 +68,11 @@ public class JDDVars
arrayBuilt = false; arrayBuilt = false;
} }
/**
* Appends a variable to this JDDVars container.
* <br>
* [ DEREFs: var (on derefAll call) ]
*/
public void addVar(JDDNode var) public void addVar(JDDNode var)
{ {
vars.addElement(var); vars.addElement(var);
@ -63,44 +80,63 @@ public class JDDVars
arrayBuilt = false; arrayBuilt = false;
} }
/**
* Appends the variables of another JDDVars container to this container.
* Does not increase the refcount of the JDDNodes!
*/
public void addVars(JDDVars ddv) public void addVars(JDDVars ddv)
{ {
int i;
vars.addAll(ddv.vars); vars.addAll(ddv.vars);
if (arrayBuilt) DDV_FreeArray(array); if (arrayBuilt) DDV_FreeArray(array);
arrayBuilt = false; arrayBuilt = false;
} }
/**
* Removes the JDDNodes contained in ddv from this JDDVars container.
* Does not decrease the refcount!
*/
public void removeVars(JDDVars ddv) public void removeVars(JDDVars ddv)
{ {
int i;
vars.removeAll(ddv.vars); vars.removeAll(ddv.vars);
if (arrayBuilt) DDV_FreeArray(array); if (arrayBuilt) DDV_FreeArray(array);
arrayBuilt = false; arrayBuilt = false;
} }
/** Returns the number of variables stored in this JDDVars container. */
public int getNumVars() public int getNumVars()
{ {
return vars.size(); return vars.size();
} }
/**
* Returns the JDDNode for the i-th stored variable.
* <br>[ REFS: <i>none</i>, DEREFS: <i>none</i> ]
*/
public JDDNode getVar(int i) public JDDNode getVar(int i)
{ {
return (JDDNode)vars.elementAt(i); return (JDDNode)vars.elementAt(i);
} }
/**
* Returns the internal Cudd pointer for the i-th stored variable.
*/
public long getVarPtr(int i) public long getVarPtr(int i)
{ {
return ((JDDNode)vars.elementAt(i)).ptr(); return ((JDDNode)vars.elementAt(i)).ptr();
} }
/**
* Returns the Cudd variable index for the i-th stored variable.
*/
public int getVarIndex(int i) public int getVarIndex(int i)
{ {
return DDV_GetIndex(((JDDNode)vars.elementAt(i)).ptr()); return DDV_GetIndex(((JDDNode)vars.elementAt(i)).ptr());
} }
/**
* Returns the minimal Cudd variable index for the stored variables,
* or -1 if there are no stored variables.
*/
public int getMinVarIndex() public int getMinVarIndex()
{ {
int i, j, n, min; int i, j, n, min;
@ -113,7 +149,11 @@ public class JDDVars
} }
return min; return min;
} }
/**
* Returns the maximal Cudd variable index for the stored variables,
* or -1 if there are no stored variables.
*/
public int getMaxVarIndex() public int getMaxVarIndex()
{ {
int i, j, n, max; int i, j, n, max;
@ -126,7 +166,10 @@ public class JDDVars
} }
return max; return max;
} }
/**
* Increases the refcount of all contained JDDNodes.
*/
public void refAll() public void refAll()
{ {
int i; int i;
@ -135,16 +178,23 @@ public class JDDVars
JDD.Ref((JDDNode)vars.elementAt(i)); JDD.Ref((JDDNode)vars.elementAt(i));
} }
} }
/**
* Decreases the refcount of all contained JDDNodes.
*/
public void derefAll() public void derefAll()
{ {
int i; int i;
for (i = 0; i < vars.size(); i++) { for (i = 0; i < vars.size(); i++) {
JDD.Deref((JDDNode)vars.elementAt(i)); JDD.Deref((JDDNode)vars.elementAt(i));
} }
} }
/**
* Constructs a JNI array for the stored variables
* that can be passed to the C-based functions.
*/
public long array() public long array()
{ {
if (arrayBuilt) { if (arrayBuilt) {
@ -156,12 +206,16 @@ public class JDDVars
return array; return array;
} }
} }
/**
* Returns the number of stored variables.
*/
public int n() public int n()
{ {
return vars.size(); return vars.size();
} }
@Override
public String toString() public String toString()
{ {
int i; int i;

Loading…
Cancel
Save