textbender.g
Class InstanceList

java.lang.Object
  extended by InstanceList

public class InstanceList
extends Object

Utilities for instance lists.


Method Summary
static
<I> int
register(I i, List<I> iList, Spool spool)
          Registers an instance, and spools it to be unregistered on disposal.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

register

public static <I> int register(I i,
                               List<I> iList,
                               Spool spool)
Registers an instance, and spools it to be unregistered on disposal. The instance is stored in place of the first null element in the list; or, if there is no null element, an element is appended to the end of the list. When unspooled, that element is set to null, effectively unregistering the instance.

Parameters:
i - instance to register
iList - list in which to register instance
spool - for internal holds. When unwound, this instance releases its internal holds, and is thence disabled.
Returns:
index at which instance is registered in the list
Throws:
AssertionError - on attempt to double-register an instance