edu.umd.cloud9.io.array
Class ArrayListOfIntsWritable

java.lang.Object
  extended by edu.umd.cloud9.util.array.ArrayListOfInts
      extended by edu.umd.cloud9.io.array.ArrayListOfIntsWritable
All Implemented Interfaces:
Cloneable, Iterable<Integer>, RandomAccess, Writable

public class ArrayListOfIntsWritable
extends ArrayListOfInts
implements Writable

Writable extension of the ArrayListOfInts 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
ArrayListOfIntsWritable()
          Constructs an ArrayListOfIntsWritable object.
ArrayListOfIntsWritable(ArrayListOfIntsWritable other)
          Constructs a deep copy of the ArrayListOfIntsWritable object given as parameter.
ArrayListOfIntsWritable(int initialCapacity)
          Constructs an empty list with the specified initial capacity.
ArrayListOfIntsWritable(int[] perm)
           
ArrayListOfIntsWritable(int firstNumber, int lastNumber)
          Constructs an ArrayListOfIntsWritable object from a given integer range [ first , last ).
 
Method Summary
 void addAll(int[] arr)
          Add all ints in the specified array into this object.
 ArrayListOfIntsWritable intersection(ArrayListOfIntsWritable other)
          Computes the intersection of two sorted lists of this type.
 void readFields(DataInput in)
          Deserializes this object.
 ArrayListOfIntsWritable sub(int start, int end)
           
 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.ArrayListOfInts
add, add, clear, clone, contains, ensureCapacity, get, getArray, indexOf, isEmpty, iterator, lastIndexOf, remove, set, setSize, shiftLastNToTop, size, toString, trimToSize
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ArrayListOfIntsWritable

public ArrayListOfIntsWritable()
Constructs an ArrayListOfIntsWritable object.


ArrayListOfIntsWritable

public ArrayListOfIntsWritable(int firstNumber,
                               int 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

ArrayListOfIntsWritable

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

Parameters:
initialCapacity - the initial capacity of the list

ArrayListOfIntsWritable

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

Parameters:
other - object to be copied

ArrayListOfIntsWritable

public ArrayListOfIntsWritable(int[] 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 ArrayListOfInts
Returns:
human-readable String representation of this ArrayList

intersection

public ArrayListOfIntsWritable intersection(ArrayListOfIntsWritable 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

sub

public ArrayListOfIntsWritable sub(int start,
                                   int end)
Parameters:
start - first index to be included in sub-list
end - last index to be included in sub-list
Returns:
return a new ArrayListOfIntsWritable object, containing the ints of this object from start to end

addAll

public void addAll(int[] arr)
Add all ints in the specified array into this object. Check for duplicates.

Parameters:
arr - array of ints to add to this object