public void finalize()
{
if(getDataset()!=null)
- getDataset().finalize();
+ getDataset().removeAlignmentRef();
dataset = null;
sequences = null;
hiddenSequences = null;
}
+ /**
+ * decrement the alignmentRefs counter by one and call finalize if it goes to zero.
+ */
+ private void removeAlignmentRef()
+ {
+ if (--alignmentRefs==0)
+ {
+ finalize();
+ }
+ }
/**
* DOCUMENT ME!
{
dataset = data;
}
+ dataset.addAlignmentRef();
+ }
+ /**
+ * reference count for number of alignments referencing this one.
+ */
+ int alignmentRefs=0;
+ /**
+ * increase reference count to this alignment.
+ */
+ private void addAlignmentRef()
+ {
+ alignmentRefs++;
}
public Alignment getDataset()