public final class FreeRing<T>
extends java.lang.Object
The free list is bounded. Freeing an object when the list is full will do nothing.
Constructor and Description |
---|
FreeRing(int capacity)
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 value)
Frees the object.
|
boolean |
freeCareful(T value)
Frees the object.
|
long |
getHead() |
long |
getHeadAlloc() |
int |
getSize() |
long |
getTail() |
long |
getTailAlloc() |
public FreeRing(int capacity)
initialSize
- maximum number of free objects to store.public int getSize()
public long getHead()
public long getHeadAlloc()
public long getTail()
public long getTailAlloc()
public T allocate()
public boolean free(T value)
obj
- the object to be freed.public boolean freeCareful(T value)
obj
- the object to be freed.public boolean checkDuplicate(T obj)