sparsebitmap
Class IntArray

java.lang.Object
  extended by sparsebitmap.IntArray
All Implemented Interfaces:
Cloneable

public class IntArray
extends Object
implements Cloneable


Constructor Summary
IntArray()
          Instantiates a new long array.
IntArray(int capacity)
          Instantiates a new long array.
 
Method Summary
 void add(int value)
          Adds a value at the end of the aarray
 int capacity()
          Return the capacity of the array, typically larger than the size of the array.
 void clear()
          Clear.
 IntArray clone()
           
 void deserialize(DataInput in)
          Deserialize
 boolean equals(Object obj)
          Determine whether these two arrays contain the same integers.
 int get(int index)
          Gets the value at index
 int hashCode()
          Return a hash value for this object.
 void removeLast()
          Removes the last value (shrinks the array)
 void serialize(DataOutput out)
          Serialize
 void set(int index, int value)
          Sets the value at index
 int size()
          Size of the array (typically smaller than the capacity).
 int trim()
          Trim the array so that the capacity is equal to the size.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IntArray

public IntArray()
Instantiates a new long array.


IntArray

public IntArray(int capacity)
Instantiates a new long array.

Parameters:
capacity - the capacity
Method Detail

clone

public IntArray clone()
               throws CloneNotSupportedException
Overrides:
clone in class Object
Throws:
CloneNotSupportedException

clear

public void clear()
Clear.


get

public int get(int index)
Gets the value at index

Parameters:
index - the index
Returns:
the value

size

public int size()
Size of the array (typically smaller than the capacity).

Returns:
the int

set

public void set(int index,
                int value)
Sets the value at index

Parameters:
index - the index
value - the value

add

public void add(int value)
Adds a value at the end of the aarray

Parameters:
value - the value

removeLast

public void removeLast()
Removes the last value (shrinks the array)


trim

public int trim()
Trim the array so that the capacity is equal to the size. This saves memory.

Returns:
the new array size (in 32-bit words)

serialize

public void serialize(DataOutput out)
               throws IOException
Serialize

Parameters:
out - the stream where we write
Throws:
IOException - Signals that an I/O exception has occurred.

deserialize

public void deserialize(DataInput in)
                 throws IOException
Deserialize

Parameters:
in - the stream where we read
Throws:
IOException - Signals that an I/O exception has occurred.

capacity

public int capacity()
Return the capacity of the array, typically larger than the size of the array.

Returns:
the capacity

hashCode

public int hashCode()
Return a hash value for this object. Uses a Karp-Rabin hash function.

Overrides:
hashCode in class Object
Returns:
the hash value

equals

public boolean equals(Object obj)
Determine whether these two arrays contain the same integers.

Overrides:
equals in class Object
Parameters:
obj - the other object (must be an IntArray to be equal)
Returns:
whether they are equal.


Copyright © 2013. All Rights Reserved.