com.ibm.dtfj.analyzer.util
Class MarkSet

java.lang.Object
  extended by com.ibm.dtfj.analyzer.util.MarkSet
Direct Known Subclasses:
ObjectMarkSet

public class MarkSet
extends java.lang.Object

Define a mark bit which can be applied to a given object ID represented by a long. We know that the incoming IDs are not necessarily dense or zero origined and so this class attempts to solve the sparse addressing problem by lazily allocating mark regions. In the case of JavaObjects we also know that they are allocated on defined boundaries and we can take advantage of that to further compress this set. See ObjectMarkSet


Field Summary
static int DEFAULT_MAX
          The default value for the max ID
static int DEFAULT_PAGE
          Size for the second level index
static int DEFAULT_TOP
          The default size of the top level index
 
Constructor Summary
MarkSet()
          Build a Mark set with default max size
MarkSet(long maxID)
          Build a Mark set with given max size
MarkSet(MarkSet copy)
          Build a Mark set as a copy of another one
 
Method Summary
 MarkSet and(MarkSet other)
          And this set with another given set and return the result.
 void clear()
          Clear all marks
 void clearMark(long id)
          Forget that the given ID has been marked
protected  void computeAnd(MarkSet other, MarkSet newSet)
           
protected  void computeOr(MarkSet other, MarkSet newSet)
           
protected  void computeXor(MarkSet other, MarkSet newSet)
           
 long countMarks()
          Count all the marks
 long getMaxID()
          What is the largest allowed mark ID
 boolean isMarked(long id)
          Has the given ID been marked
 MarkSet or(MarkSet other)
          Or this set with another given set and return the result.
 void setMark(long id)
          Remember that the given ID has been marked
 MarkSet xor(MarkSet other)
          Exclusive or this set with another given set and return the result.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TOP

public static final int DEFAULT_TOP
The default size of the top level index

See Also:
Constant Field Values

DEFAULT_PAGE

public static final int DEFAULT_PAGE
Size for the second level index

See Also:
Constant Field Values

DEFAULT_MAX

public static final int DEFAULT_MAX
The default value for the max ID

See Also:
Constant Field Values
Constructor Detail

MarkSet

public MarkSet()
Build a Mark set with default max size


MarkSet

public MarkSet(long maxID)
Build a Mark set with given max size

Parameters:
maxID - value of largest allowed ID

MarkSet

public MarkSet(MarkSet copy)
Build a Mark set as a copy of another one

Parameters:
copy - the set to copy
Method Detail

getMaxID

public long getMaxID()
What is the largest allowed mark ID

Returns:
largest mark ID or 0 to indicate unlimited

setMark

public void setMark(long id)
Remember that the given ID has been marked

Parameters:
id - the ID to mark

clearMark

public void clearMark(long id)
Forget that the given ID has been marked

Parameters:
id - the ID to unmark

isMarked

public boolean isMarked(long id)
Has the given ID been marked

Parameters:
id - the required ID
Returns:
true if marked

clear

public void clear()
Clear all marks


countMarks

public long countMarks()
Count all the marks

Returns:
the total of marked items

and

public MarkSet and(MarkSet other)
And this set with another given set and return the result. The result will have a mark if both sets have a mark.

Parameters:
other - the set to and this one with
Returns:
the resulting set - > (this & set)

computeAnd

protected void computeAnd(MarkSet other,
                          MarkSet newSet)

or

public MarkSet or(MarkSet other)
Or this set with another given set and return the result. The result will have a mark if either set has a mark.

Parameters:
other - the set to or this one with
Returns:
the resulting set - > (this | set)

computeOr

protected void computeOr(MarkSet other,
                         MarkSet newSet)

xor

public MarkSet xor(MarkSet other)
Exclusive or this set with another given set and return the result. The result will have a mark if either this set or the other has a mark but not both.

Parameters:
other - the set to or this one with
Returns:
the resulting set - > (this ^ set)

computeXor

protected void computeXor(MarkSet other,
                          MarkSet newSet)


© Copyright IBM Corp. 2007, 2008 All Rights Reserved. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.