com.threerings.presents.dobj
Class OidList

java.lang.Object
  extended by com.threerings.presents.dobj.OidList
All Implemented Interfaces:
Streamable, Iterable<Integer>

public class OidList
extends Object
implements Streamable, Iterable<Integer>

An oid list is used to store lists of object ids. The list will not allow duplicate ids. This class is not synchronized, with the expectation that all modifications of instances will take place on the dobjmgr thread.


Nested Class Summary
protected  class OidList.OidIterator
           
 
Nested classes/interfaces inherited from interface com.threerings.io.Streamable
Streamable.Closure
 
Field Summary
protected static int DEFAULT_SIZE
           
 
Constructor Summary
OidList()
          Creates an empty oid list.
OidList(int initialSize)
          Creates an empty oid list with space for at least initialSize object ids before it will need to expand.
 
Method Summary
 boolean add(int oid)
          Adds the specified object id to the list if it is not already there.
 boolean contains(int oid)
          Returns true if the specified oid is in the list, false if not.
 int get(int index)
          Returns the object id at the specified index.
 Iterator<Integer> iterator()
           
 boolean remove(int oid)
          Removes the specified oid from the list.
 int size()
          Returns the number of object ids in the list.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_SIZE

protected static final int DEFAULT_SIZE
See Also:
Constant Field Values
Constructor Detail

OidList

public OidList()
Creates an empty oid list.


OidList

public OidList(int initialSize)
Creates an empty oid list with space for at least initialSize object ids before it will need to expand.

Method Detail

size

public int size()
Returns the number of object ids in the list.


add

public boolean add(int oid)
Adds the specified object id to the list if it is not already there.

Returns:
true if the object was added, false if it was already in the list.

remove

public boolean remove(int oid)
Removes the specified oid from the list.

Returns:
true if the oid was in the list and was removed, false otherwise.

contains

public boolean contains(int oid)
Returns true if the specified oid is in the list, false if not.


get

public int get(int index)
Returns the object id at the specified index. This does no boundary checking.


toString

public String toString()
Overrides:
toString in class Object

iterator

public Iterator<Integer> iterator()
Specified by:
iterator in interface Iterable<Integer>