edu.neu.ccs.quick
Class BooleanStateArray

java.lang.Object
  extended byedu.neu.ccs.quick.BooleanStateArray

public class BooleanStateArray
extends Object

The class BooleanStateArray tracks a boolean state corresponding to a list of int keys provided in the class constructor.

Since:
2.5.0
Version:
2.5.0

Field Summary
private  int[] keys
          The array of int keys.
private  boolean[] states
          The corresponding array of boolean states.
 
Constructor Summary
BooleanStateArray(int[] list)
          Initializes the BooleanStateArray with the list of keys whose boolean state will be maintained.
 
Method Summary
 boolean getState(int key)
          Returns the boolean state of the given key.
 void setAllStates(boolean state)
          Sets all states to the given state.
 void setState(int[] list, boolean state)
          Sets the states in the given list of keys to the given state.
 void setState(int key, boolean state)
          Sets the boolean state of the given key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

keys

private int[] keys
The array of int keys.


states

private boolean[] states
The corresponding array of boolean states.

Constructor Detail

BooleanStateArray

public BooleanStateArray(int[] list)

Initializes the BooleanStateArray with the list of keys whose boolean state will be maintained.

This list cannot be changed after construction.

If the given list contains duplicate int entries, such duplicates will be removed in the internal data structure.

Parameters:
list - the list of keys that will be associated with boolean states
Method Detail

getState

public boolean getState(int key)

Returns the boolean state of the given key.

Returns false if the key was not given in the list provided to the constructor.

Parameters:
key - the key whose state is desired

setState

public void setState(int key,
                     boolean state)

Sets the boolean state of the given key.

Does nothing if the key was not given in the list provided to the constructor.

Parameters:
key - the key whose state is to be set
state - the state to set

setState

public void setState(int[] list,
                     boolean state)

Sets the states in the given list of keys to the given state.

Parameters:
list - the list of keys whose state is to be set
state - the state to set

setAllStates

public void setAllStates(boolean state)

Sets all states to the given state.

Parameters:
state - the state to set