net.morbz.minecraft.world
Class NibbleArray

java.lang.Object
  extended by net.morbz.minecraft.world.NibbleArray

public class NibbleArray
extends java.lang.Object

This is an array for nibbles (4-bit values).

Author:
MorbZ

Constructor Summary
NibbleArray(int size)
          Creates a new instance.
 
Method Summary
 byte get(int index)
          Gets an element.
 byte[] getBytes()
          Returns the byte array that holds the nibble values.
 void set(int index, byte value)
          Sets an element.
 int size()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NibbleArray

public NibbleArray(int size)
Creates a new instance.

Parameters:
size - The number elements that the array can hold
Method Detail

set

public void set(int index,
                byte value)
Sets an element.

Parameters:
index - The index of the element
value - The value of the element

get

public byte get(int index)
Gets an element.

Parameters:
index - The index of the element
Returns:
The value of the element

size

public int size()
Returns:
The number of elements

getBytes

public byte[] getBytes()
Returns the byte array that holds the nibble values. In case the size of the nibble array is odd the last byte will only hold one nibble.

Returns:
The byte array