public final class FreeList<T>
extends java.lang.Object
The free list is bounded. Freeing an object when the list is full will do nothing.
Constructor and Description |
---|
FreeList(int size)
Create a new free list.
|
Modifier and Type | Method and Description |
---|---|
T |
allocate()
Try to get an object from the free list.
|
boolean |
checkDuplicate(T obj)
Debugging to see if the object has already been freed.
|
boolean |
free(T obj)
Frees the object.
|
boolean |
freeCareful(T obj)
Frees the object.
|
public FreeList(int size)
initialSize
- maximum number of free objects to store.public T allocate()
public boolean free(T obj)
obj
- the object to be freed.public boolean freeCareful(T obj)
obj
- the object to be freed.public boolean checkDuplicate(T obj)