JanosVM v1.0 API

edu.utah.janosvm.kit.util
Class SparseArray

java.lang.Object
  |
  +--edu.utah.janosvm.kit.util.SparseArray

public final class SparseArray
extends java.lang.Object

A simple class for generating/looking up unique identifiers.


Field Summary
static int DEFAULT_ID_BITS
          The number of bits that make up a unique identifier.
static int DEFAULT_X_SIZE
          The default X size of the array.
static int DEFAULT_Y_SIZE
          The default Y size of the array.
private  java.lang.Class elementClass
          The class of elements that should be used in the array.
static int INVALID_ID
          A guaranteed invalid ID number.
private  int timeBitCount
          The number of bits in the delay mask.
private  long timeMask
          The bitmask that makes up the delay.
private  int xBitCount
          The number of bits used to index the X dimension.
private  SparseArrayDimension[] xDimension
          The X dimension.
private  int xSize
          The size of the X dimension.
private  int xUsed
          The number of slots actually used in the X dimension.
private  int yBitCount
          The number of bits used to index the Y dimension.
private  int ySize
          The size of the Y dimension.
 
Constructor Summary
SparseArray()
          Construct an array with the default values.
SparseArray(java.lang.Class cl)
          Construct an array with the given values and the default sizes.
SparseArray(java.lang.Class elementClass, int xSize, int ySize, int timeBitCount)
          Construct an array with the given values.
SparseArray(int xSize, int ySize)
          Construct an array with the given values and the default element class.
 
Method Summary
private static int bitCount(int bits)
          Count the number of bits set in the given integer.
 void dropElement(SparseArrayElement sae)
           
 java.util.Enumeration elements()
           
 SparseArrayElement findElement(long id)
           
 SparseArrayElement getElement()
           
 java.lang.Class getElementClass()
           
 int getTimeCount()
           
 long getTimeMask()
           
 int getTimeOffset()
           
 int getXSize()
           
 int getYSize()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait, wait0
 

Field Detail

DEFAULT_X_SIZE

public static final int DEFAULT_X_SIZE
The default X size of the array.

DEFAULT_Y_SIZE

public static final int DEFAULT_Y_SIZE
The default Y size of the array.

DEFAULT_ID_BITS

public static final int DEFAULT_ID_BITS
The number of bits that make up a unique identifier.

INVALID_ID

public static final int INVALID_ID
A guaranteed invalid ID number.

elementClass

private java.lang.Class elementClass
The class of elements that should be used in the array.

xSize

private int xSize
The size of the X dimension.

xBitCount

private int xBitCount
The number of bits used to index the X dimension.

xUsed

private int xUsed
The number of slots actually used in the X dimension.

ySize

private int ySize
The size of the Y dimension.

yBitCount

private int yBitCount
The number of bits used to index the Y dimension.

timeBitCount

private int timeBitCount
The number of bits in the delay mask.

timeMask

private long timeMask
The bitmask that makes up the delay.

xDimension

private final SparseArrayDimension[] xDimension
The X dimension.
Constructor Detail

SparseArray

public SparseArray(java.lang.Class elementClass,
                   int xSize,
                   int ySize,
                   int timeBitCount)
Construct an array with the given values.
Parameters:
elementClass - The class of objects to use as elements.
xSize - The size of the X dimension.
ySize - The size of the Y dimension.

SparseArray

public SparseArray(int xSize,
                   int ySize)
Construct an array with the given values and the default element class.
Parameters:
xSize - The size of the X dimension.
ySize - The size of the Y dimension.

SparseArray

public SparseArray(java.lang.Class cl)
Construct an array with the given values and the default sizes.
Parameters:
elementClass - The class of objects to use as elements.

SparseArray

public SparseArray()
Construct an array with the default values.
Method Detail

bitCount

private static int bitCount(int bits)
Count the number of bits set in the given integer. XXX This sucks.
Parameters:
bits - A value with a few bits set.
Returns:
The number of bits in `bits' that are 1.

getElementClass

public java.lang.Class getElementClass()
Returns:
The class of elements in the array.

getXSize

public int getXSize()
Returns:
The size of the X dimension.

getYSize

public int getYSize()
Returns:
The size of the Y dimension.

getTimeCount

public int getTimeCount()
Returns:
The number of bits in the delay mask.

getTimeOffset

public int getTimeOffset()
Returns:
The start of the delay bits.

getTimeMask

public long getTimeMask()
Returns:
The bitmask that makes up the delay.

getElement

public SparseArrayElement getElement()
Returns:
An allocated SparseArrayElement.

dropElement

public void dropElement(SparseArrayElement sae)
Parameters:
sae - A SparseArrayElement to free.

findElement

public SparseArrayElement findElement(long id)
Parameters:
id - The element to find.
Returns:
The element with the given identifier or null if it wasn't found

elements

public java.util.Enumeration elements()
Returns:
An enumeration containing the elements in the array. NOTE: You

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

JanosVM v1.0 API

This documentation is Copyright (C) 2000-2003 The University of Utah. All Rights Reserved. See the documentation license for distribution terms and restrictions.
Documentation, software, and mailing lists for the JanosVM can be found at the Janos Project web page: http://www.cs.utah.edu/flux/janos/
Generated on Feb 13, 2003