visad.data.visad
Class BinaryObjectCache

java.lang.Object
  extended by visad.data.visad.BinaryObjectCache

public class BinaryObjectCache
extends Object

A list which allows objects to be added at a specific index, padding with nulls if necessary.


Constructor Summary
BinaryObjectCache()
          Create an empty list.
 
Method Summary
 int add(int index, Object obj)
          Add an object to the end of the list.
 int add(Object obj)
          Add an object at the specified index.
 Object get(int index)
          Return the object found at the specified index.
 int getIndex(Object obj)
          Return the index of the specified object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BinaryObjectCache

public BinaryObjectCache()
Create an empty list.

Method Detail

add

public int add(Object obj)
Add an object at the specified index.

Parameters:
obj - Object to be added.
Returns:
-1 if the object is null, or the index at which the object was added.

add

public int add(int index,
               Object obj)
Add an object to the end of the list. If the index is less than zero, the object will be added to the end of the list.

Parameters:
obj - Object to be added.
Returns:
-1 if the object is null, or the index at which the object was added.

get

public Object get(int index)
           throws IndexOutOfBoundsException
Return the object found at the specified index.

Parameters:
index - Object index.
Returns:
The requested object.
Throws:
IndexOutOfBoundsException - If the index is outside the list bounds.

getIndex

public int getIndex(Object obj)
Return the index of the specified object.

Parameters:
obj - Object to find in the list,
Returns:
-1 if the object was not found, or the index of the object.