edu.umd.cloud9.io.array
Class ArrayListOfShortsWritable

java.lang.Object
  extended by edu.umd.cloud9.util.array.ArrayListOfShorts
      extended by edu.umd.cloud9.io.array.ArrayListOfShortsWritable
All Implemented Interfaces:
Cloneable, Iterable<Short>, RandomAccess, Writable

public class ArrayListOfShortsWritable
extends ArrayListOfShorts
implements Writable

Writable extension of the ArrayListOfShorts class. This class allows the user to have an efficient data structure to store a list of integers in MapReduce tasks. It is especially useful for storing index lists, as it has an efficient intersection method.

Author:
Ferhan Ture

Constructor Summary
ArrayListOfShortsWritable()
          Constructs an ArrayListOfIntsWritable object.
ArrayListOfShortsWritable(ArrayListOfShortsWritable other)
          Constructs a deep copy of the ArrayListOfIntsWritable object given as parameter.
ArrayListOfShortsWritable(int initialCapacity)
          Constructs an empty list with the specified initial capacity.
ArrayListOfShortsWritable(short[] perm)
           
ArrayListOfShortsWritable(short firstNumber, short lastNumber)
          Constructs an ArrayListOfIntsWritable object from a given integer range [ first , last ).
 
Method Summary
 ArrayListOfShortsWritable intersection(ArrayListOfShortsWritable other)
          Computes the intersection of two sorted lists of this type.
 void readFields(DataInput in)
          Deserializes this object.
 String toString()
          Generates human-readable String representation of this ArrayList.
 void write(DataOutput out)
          Serializes this object.
 
Methods inherited from class edu.umd.cloud9.util.array.ArrayListOfShorts
add, add, clear, clone, contains, ensureCapacity, get, getArray, indexOf, isEmpty, iterator, lastIndexOf, remove, set, setSize, size, toString, trimToSize
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ArrayListOfShortsWritable

public ArrayListOfShortsWritable()
Constructs an ArrayListOfIntsWritable object.


ArrayListOfShortsWritable

public ArrayListOfShortsWritable(short firstNumber,
                                 short lastNumber)
Constructs an ArrayListOfIntsWritable object from a given integer range [ first , last ). The created list includes the first parameter but excludes the second.

Parameters:
firstNumber - the smallest integer in the range
lastNumber - the largest integer in the range

ArrayListOfShortsWritable

public ArrayListOfShortsWritable(int initialCapacity)
Constructs an empty list with the specified initial capacity.

Parameters:
initialCapacity - the initial capacity of the list

ArrayListOfShortsWritable

public ArrayListOfShortsWritable(ArrayListOfShortsWritable other)
Constructs a deep copy of the ArrayListOfIntsWritable object given as parameter.

Parameters:
other - object to be copied

ArrayListOfShortsWritable

public ArrayListOfShortsWritable(short[] perm)
Method Detail

readFields

public void readFields(DataInput in)
                throws IOException
Deserializes this object.

Specified by:
readFields in interface Writable
Parameters:
in - source for raw byte representation
Throws:
IOException

write

public void write(DataOutput out)
           throws IOException
Serializes this object.

Specified by:
write in interface Writable
Parameters:
out - where to write the raw byte representation
Throws:
IOException

toString

public String toString()
Generates human-readable String representation of this ArrayList.

Overrides:
toString in class ArrayListOfShorts
Returns:
human-readable String representation of this ArrayList

intersection

public ArrayListOfShortsWritable intersection(ArrayListOfShortsWritable other)
Computes the intersection of two sorted lists of this type. This method is tuned for efficiency, therefore this ArrayListOfIntsWritable and the parameter are both assumed to be sorted in an increasing order. The ArrayListOfIntsWritable that is returned is the intersection of this object and the parameter. That is, the returned list will only contain the elements that occur in both this object and other.

Parameters:
other - other ArrayListOfIntsWritable that is intersected with this object
Returns:
intersection of other and this object