public class HandleDataStore
extends java.lang.Object
implements java.io.Serializable
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_MAX_CAPACITY
Default maximum capacity of this ADT.
|
| Constructor and Description |
|---|
HandleDataStore()
Constructs a
HandleDataStore with zero offset and initial capacity of ten. |
HandleDataStore(int initialCapacity)
Constructs a
HandleDataStore with zero offset. |
HandleDataStore(int initialCapacity,
int maxCapacity)
Constructs a
HandleDataStore. |
| Modifier and Type | Method and Description |
|---|---|
void |
ackAllocation(int handle)
Completes allocation of handle, to be used to completely allocate handle after preallocation.
|
int |
allocate()
Allocate an element in this
HandleDataStore. |
int |
allocate(int handle)
Allocate an element in this
HandleDataStore. |
int |
allocate(int handle,
boolean preallocate)
Allocate an element with given handle in this
HandleDataStore. |
int |
capacity()
Returns the capacity of this ADT.
|
void |
deallocate(int handle)
Deallocate an element with the given handle.
|
void |
deallocate(int handle,
boolean depreallocate)
Deallocate an element with the given handle.
|
int |
first()
Return the handle of the first element in this ADT.
|
java.lang.Object |
get(int handle)
Returns the element with the specified handle.
|
boolean |
isAllocated(int handle)
Determines whether a given handle is allocated.
|
boolean |
isEmpty()
Tests if this list has no elements.
|
int |
last()
Return the handle of the last element in this ADT.
|
int |
next(int handle)
Return the handle of the next element in this ADT.
|
int |
preallocate()
Preallocate an element in this
HandleDataStore. |
int |
previous(int handle)
Return the handle of the previous element in this ADT.
|
void |
set(int handle,
java.lang.Object data)
Sets the element with the specified handle.
|
void |
setCapacity(int newCapacity)
Sets the capacity of this
HandleDataStore instance to
hold newCapacity elements;. |
int |
size()
Returns the number of elements in this ADT.
|
java.lang.String |
toString()
Returns a single-line rendition of this instance into text.
|
public static final int DEFAULT_MAX_CAPACITY
public HandleDataStore()
HandleDataStore with zero offset and initial capacity of ten.public HandleDataStore(int initialCapacity)
HandleDataStore with zero offset.initialCapacity - the initial capacity of the list.java.lang.IllegalArgumentException - if the specified initial capacity is negativepublic HandleDataStore(int initialCapacity,
int maxCapacity)
HandleDataStore.
Creates a HandleDataStore and allocates enough space to hold initialCapacity elements.initialCapacity - the initial capacity of the list.java.lang.IllegalArgumentException - if the specified initial capacity is negativepublic int size()
public int capacity()
public boolean isEmpty()
true if this list has no elements, false otherwise.public java.lang.Object get(int handle)
handle is not checked, if it is valid.handle - handle of the elementjava.lang.IndexOutOfBoundsException - if handle is out of bounds.public void set(int handle,
java.lang.Object data)
handle is not checked, if it is valid.handle - handle of the elementdata - data to be setjava.lang.IndexOutOfBoundsException - if handle is out of bounds.public void setCapacity(int newCapacity)
HandleDataStore instance to
hold newCapacity elements;.newCapacity - the desired capacity.public int first()
next(int),
previous(int),
lastpublic int last()
next(int),
previous(int),
firstpublic int next(int handle)
handle - handle of the element whose sucessor's handle we wish to acquire.handle.
If handle is the last element, 0 is returned.public int previous(int handle)
handle - handle of the element whose predecessor's handle we wish to acquire.handle.
If handle is the first element, 0 is returned.public boolean isAllocated(int handle)
handle - the handle in question.true if an element with handle handle already
exists in this ADT, false otherwise.public int allocate()
HandleDataStore.0deallocate(int)public int allocate(int handle)
HandleDataStore.handle - hanlde be allocated0deallocate(int)public int preallocate()
HandleDataStore.0allocate(),
deallocate(int)public int allocate(int handle,
boolean preallocate)
HandleDataStore.
Assures that this ADT is capable of holding yet another element
and returns a handle to it.handle - handle to be allocatedpreallocate - if true element is not really allocated (only reserved,
listing through the ADT will skip preallocated elements), to completely allocate
preallocated elements use ackAllocation(handle) or canceled by
deallocate(handle, true) method.0deallocate(int)public void ackAllocation(int handle)
handle - handle to be completely allocatedpublic void deallocate(int handle)
allocate.handle - the handle of the element to deallocate.allocate()public void deallocate(int handle,
boolean depreallocate)
allocate.handle - the handle of the element to deallocate.depreallocate - has to be true, if handle was only preallocatedallocate()public java.lang.String toString()
toString in class java.lang.Object