com.threerings.miso.util
Class ObjectSet

java.lang.Object
  extended by com.threerings.miso.util.ObjectSet

public class ObjectSet
extends Object

Used to store an (arbitrarily) ordered, low-impact iteratable (doesn't require object creation), set of ObjectInfo instances.


Field Summary
protected  Object[] _objs
          Our sorted array of objects.
protected  int _size
          The number of objects in the set.
protected static int DEFAULT_SIZE
          We start big because we know these will in general contain at least in the tens of objects.
protected static Comparator<Object> INFO_COMP
          We simply sort the objects in order of their hash code.
 
Constructor Summary
ObjectSet()
           
 
Method Summary
 void clear()
          Clears out the contents of this set.
 boolean contains(ObjectInfo info)
          Returns true if the specified object is in the set, false if it is not.
 ObjectInfo get(int index)
          Returns the object with the specified index.
protected  int indexOf(ObjectInfo info)
          Returns the index of the object or its insertion index if it is not in the set.
 boolean insert(ObjectInfo info)
          Inserts the supplied object into the set.
 void remove(int index)
          Removes the object at the specified index.
 boolean remove(ObjectInfo info)
          Removes the specified object from the set.
 int size()
          Returns the number of objects in this set.
 ObjectInfo[] toArray()
          Converts the contents of this object set to an array.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_objs

protected Object[] _objs
Our sorted array of objects.


_size

protected int _size
The number of objects in the set.


INFO_COMP

protected static final Comparator<Object> INFO_COMP
We simply sort the objects in order of their hash code. We don't care about their order, it exists only to support binary search.


DEFAULT_SIZE

protected static final int DEFAULT_SIZE
We start big because we know these will in general contain at least in the tens of objects.

See Also:
Constant Field Values
Constructor Detail

ObjectSet

public ObjectSet()
Method Detail

insert

public boolean insert(ObjectInfo info)
Inserts the supplied object into the set.

Returns:
true if it was inserted, false if the object was already in the set.

contains

public boolean contains(ObjectInfo info)
Returns true if the specified object is in the set, false if it is not.


size

public int size()
Returns the number of objects in this set.


get

public ObjectInfo get(int index)
Returns the object with the specified index. The index must & be between 0 and size()-1.


remove

public void remove(int index)
Removes the object at the specified index.


remove

public boolean remove(ObjectInfo info)
Removes the specified object from the set.

Returns:
true if it was removed, false if it was not in the set.

clear

public void clear()
Clears out the contents of this set.


toArray

public ObjectInfo[] toArray()
Converts the contents of this object set to an array.


toString

public String toString()
Overrides:
toString in class Object

indexOf

protected final int indexOf(ObjectInfo info)
Returns the index of the object or its insertion index if it is not in the set.