org.egothor.util
Class IntegerArray

java.lang.Object
  extended by org.egothor.util.IntegerArray

public class IntegerArray
extends java.lang.Object

This class offers a dynamic array of integers. The array is technically broken up into several smaller integer arrays of size 2FRAGSIZE2POW. If the array fragment does not contain any value it is not allocated at all and its values are supposed to be 0.


Constructor Summary
IntegerArray()
           
IntegerArray(DataInput in)
           
 
Method Summary
 void clear()
           
 int dec(int index)
           
 int divadd(int by, IntegerArray addition)
          Calculates this/by+addition (this and addition are vectors).
 void dump(java.io.PrintStream out, int from_index)
           
 int get(int index)
           
 int highestSet()
          Highest index set by @{link #set} method.
 void inc(int index, int byvalue)
           
 void set(int index, int value)
           
 void store(DataOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IntegerArray

public IntegerArray()

IntegerArray

public IntegerArray(DataInput in)
             throws java.io.IOException
Throws:
java.io.IOException
Method Detail

clear

public void clear()

divadd

public int divadd(int by,
                  IntegerArray addition)
Calculates this/by+addition (this and addition are vectors). The maximum difference between the current vector and the vector after calculation is returned.

Returns:
the maximum difference in any cell after the calculation, -1 when vectors are not fragmented the same way or when addition is empty

dump

public void dump(java.io.PrintStream out,
                 int from_index)

store

public void store(DataOutput out)
           throws java.io.IOException
Throws:
java.io.IOException

highestSet

public int highestSet()
Highest index set by @{link #set} method.

Returns:
the highest offset occupied by some user-set value, or -1 when @{link #set} was not called yet
See Also:
set(int, int)

set

public void set(int index,
                int value)

get

public int get(int index)

inc

public void inc(int index,
                int byvalue)

dec

public int dec(int index)