Extension SDK 10.1.2

oracle.javatools.editor.language
Class BooleanBitmap

java.lang.Object
  extended byoracle.javatools.editor.language.BooleanBitmap

public final class BooleanBitmap
extends java.lang.Object

The BooleanBitmap is a bitmap, or array, of boolean values. This helps to reduce the size of the array to a single bit per entry rather than 1 byte per entry at the expense of extra overhead to access the information.

Note that the bitmap does not expand automatically when you access an entry beyond the end of the bitmap - you must explicitly expand the bitmap using setSize(). Also note that if you do not provide a boolean fill value to use for initialization, all (new) entries will be left uninitialized when the bitmap is created or expanded.


Constructor Summary
BooleanBitmap(int initialSize)
          Constructs a new BooleanBitmap with the given size, with no automatic initialization performed.
BooleanBitmap(int initialSize, boolean defaultFill)
          Constructs a new BooleanBitmap with the given size, with automatic initialization to the given fill value.
 
Method Summary
 boolean get(int index)
          Fetches the boolean value in the bitmap at the given index, which is 0-based.
 int getSize()
          Fetches the size of the BooleanBitmap in terms of the number of entries it holds.
 void set(int index, boolean newValue)
          Sets the boolean value in the bitmap at the given index, which is 0-based.
 void setSize(int requestedSize)
          Sets the size of the BooleanBitmap to the given specified user size.
 java.lang.String toString()
          Fetch the boolean values of this bitmap as a sequence of 0's and 1's, starting with the 0 offset on the very left.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BooleanBitmap

public BooleanBitmap(int initialSize)
Constructs a new BooleanBitmap with the given size, with no automatic initialization performed. If you need the Bitmap to ensure that all entries are initialized to some fill value before use, you must use the alternate constructor call and specify the fill value.

Parameters:
initialSize - the size of the bitmap in boolean entries

BooleanBitmap

public BooleanBitmap(int initialSize,
                     boolean defaultFill)
Constructs a new BooleanBitmap with the given size, with automatic initialization to the given fill value.

Parameters:
initialSize - the size of the bitmap in boolean entries
defaultFill - the user's default fill to use
Method Detail

getSize

public int getSize()
Fetches the size of the BooleanBitmap in terms of the number of entries it holds. The size of the bitmap is determined by the initial size of the bitmap (if it is newly created) or by the last call to setSize().


setSize

public void setSize(int requestedSize)
Sets the size of the BooleanBitmap to the given specified user size. The bitmap will be expanded (with additional data values initialized to the given fill), or shrunk depending on requestedSize.

Parameters:
requestedSize - the new size of the bitmap

get

public boolean get(int index)
            throws java.lang.IndexOutOfBoundsException
Fetches the boolean value in the bitmap at the given index, which is 0-based. Note that the bitmap holds getSize() entries, so this index should be from 0 to getSize()-1. If the index is beyond the size of the bitmap, an IndexOutOfBoundsException will be thrown.

Parameters:
index - the index of the boolean value to get
Returns:
the value at the given index
Throws:
throws - an IndexOutOfBoundsException if the index is not within the proper range of the bitmap
java.lang.IndexOutOfBoundsException

set

public void set(int index,
                boolean newValue)
Sets the boolean value in the bitmap at the given index, which is 0-based. Note that the bitmap holds getSize() entries, so this index should be from 0 to getSize()-1. If the index is beyond the size of the bitmap, an IndexOutOfBoundsException will be thrown.

Parameters:
index - the index of the boolean value to set
newValue - the new value to set at the given index
Throws:
throws - an IndexOutOfBoundsException if the index is not within the proper range of the bitmap

toString

public java.lang.String toString()
Fetch the boolean values of this bitmap as a sequence of 0's and 1's, starting with the 0 offset on the very left.

Returns:
the string representation

Extension SDK

 

Copyright © 1997, 2004, Oracle. All rights reserved.