

Classes | |
| class | Element |
Public Member Functions | |
| HandleDataStore () | |
| HandleDataStore (int initialCapacity) | |
| HandleDataStore (int initialCapacity, int maxCapacity) | |
| int | size () |
| int | capacity () |
| boolean | isEmpty () |
| Object | get (int handle) |
| void | set (int handle, Object data) |
| void | setCapacity (int newCapacity) |
| int | first () |
| int | last () |
| int | next (int handle) |
| int | previous (int handle) |
| boolean | isAllocated (int handle) |
| int | allocate () |
| int | allocate (int handle) |
| int | preallocate () |
| int | allocate (int handle, boolean preallocate) |
| void | ackAllocation (int handle) |
| void | deallocate (int handle) |
| void | deallocate (int handle, boolean depreallocate) |
| String | toString () |
Static Public Attributes | |
| static final int | DEFAULT_MAX_CAPACITY = Integer.MAX_VALUE |
Private Attributes | |
| int | capacity |
| int | maxCapacity = DEFAULT_MAX_CAPACITY |
| int | size |
| Element[] | elements |
| int | first |
| int | last |
Static Private Attributes | |
| static final long | serialVersionUID = -6137572272422678754L |
Data structure for maintaining a collection of elements that can be referred to using handles.
Stores data elements in an array-like structure. Individual elements are addressed using handles, which can be though of as indices in the array. It fulfills these requirements:
This ADT is suitable for enumerating resources that are frequently allocated, retrieved and deallocated without losing large amounts of memory and/or time.
This is essentially a doubly-linked list of elements, which are placed in an array. Each element has assigned a handle (the index in the array), and handles of the elements that come previous and next to it. There are actually two chains of elements: the free element chain, which contains all elements that have not yet been allocated, and the allocated element chain. Free element chain is cyclic (passing the end resumes at the beginning), and contains the element with the handle 0. The allocated element chain is not cyclic: it starts with the element that was first allocated, and ends with the one that was last allocated.
| com::cosylab::acs::maci::manager::HandleDataStore::HandleDataStore | ( | ) | [inline] |
Amount by which to offset all handles. Constructs a HandleDataStore with zero offset and initial capacity of ten.
References DEFAULT_MAX_CAPACITY.
| com::cosylab::acs::maci::manager::HandleDataStore::HandleDataStore | ( | int | initialCapacity | ) | [inline] |
Constructs a HandleDataStore with zero offset.
| initialCapacity | the initial capacity of the list. |
| IllegalArgumentException | if the specified initial capacity is negative |
References DEFAULT_MAX_CAPACITY.
| com::cosylab::acs::maci::manager::HandleDataStore::HandleDataStore | ( | int | initialCapacity, | |
| int | maxCapacity | |||
| ) | [inline] |
Constructs a HandleDataStore.
Creates a HandleDataStore and allocates enough space to hold initialCapacity elements.
| initialCapacity | the initial capacity of the list. |
| IllegalArgumentException | if the specified initial capacity is negative |
References setCapacity().
| void com::cosylab::acs::maci::manager::HandleDataStore::ackAllocation | ( | int | handle | ) | [inline] |
Completes allocation of handle, to be used to completely allocate handle after preallocation.
| handle | handle to be completely allocated |
References elements, first(), last(), com::cosylab::acs::maci::manager::HandleDataStore::Element::next, and com::cosylab::acs::maci::manager::HandleDataStore::Element::previous.
Referenced by allocate().
| int com::cosylab::acs::maci::manager::HandleDataStore::allocate | ( | int | handle, | |
| boolean | preallocate | |||
| ) | [inline] |
Allocate an element with given handle in this HandleDataStore.
Assures that this ADT is capable of holding yet another element and returns a handle to it.
| handle | handle to be allocated | |
| preallocate | 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. |
0 References ackAllocation(), capacity(), elements, com::cosylab::acs::maci::manager::HandleDataStore::Element::free, maxCapacity, com::cosylab::acs::maci::manager::HandleDataStore::Element::next, com::cosylab::acs::maci::manager::HandleDataStore::Element::previous, setCapacity(), and size().
| int com::cosylab::acs::maci::manager::HandleDataStore::allocate | ( | int | handle | ) | [inline] |
Allocate an element in this HandleDataStore.
| handle | hanlde be allocated |
0 References allocate().
| int com::cosylab::acs::maci::manager::HandleDataStore::allocate | ( | ) | [inline] |
Allocate an element in this HandleDataStore.
0 References elements, and next().
Referenced by com::cosylab::acs::maci::test::HandleDataStoreTest::allocate(), allocate(), preallocate(), com::cosylab::acs::maci::test::HandleDataStoreTest::testDefaultAllocation(), and com::cosylab::acs::maci::test::HandleDataStoreTest::testFreeAllocation().
| int com::cosylab::acs::maci::manager::HandleDataStore::capacity | ( | ) | [inline] |
Returns the capacity of this ADT.
Capacity is the maximum number of elements that this ADT can hold before resizing itself.
Referenced by allocate(), isAllocated(), setCapacity(), and toString().
| void com::cosylab::acs::maci::manager::HandleDataStore::deallocate | ( | int | handle, | |
| boolean | depreallocate | |||
| ) | [inline] |
Deallocate an element with the given handle.
The element and its corresponding handle can be reused at a later call to allocate.
| handle | the handle of the element to deallocate. | |
| depreallocate | has to be true, if handle was only preallocated |
References com::cosylab::acs::maci::manager::HandleDataStore::Element::data, elements, first(), com::cosylab::acs::maci::manager::HandleDataStore::Element::free, last(), next(), com::cosylab::acs::maci::manager::HandleDataStore::Element::next, com::cosylab::acs::maci::manager::HandleDataStore::Element::previous, previous(), and size().
| void com::cosylab::acs::maci::manager::HandleDataStore::deallocate | ( | int | handle | ) | [inline] |
Deallocate an element with the given handle.
The element and its corresponding handle can be reused at a later call to allocate.
| handle | the handle of the element to deallocate. |
Referenced by com::cosylab::acs::maci::test::HandleDataStoreTest::deallocate(), and com::cosylab::acs::maci::test::HandleDataStoreTest::testFreeAllocation().
| int com::cosylab::acs::maci::manager::HandleDataStore::first | ( | ) | [inline] |
Return the handle of the first element in this ADT.
Referenced by ackAllocation(), deallocate(), and toString().
| Object com::cosylab::acs::maci::manager::HandleDataStore::get | ( | int | handle | ) | [inline] |
Returns the element with the specified handle.
NOTE: handle is not checked, if it is valid.
| handle | handle of the element |
| IndexOutOfBoundsException | if handle is out of bounds. |
References com::cosylab::acs::maci::manager::HandleDataStore::Element::data, and elements.
Referenced by com::cosylab::acs::maci::manager::ManagerImpl::administratorLogin(), com::cosylab::acs::maci::manager::ManagerImpl::administratorLogout(), com::cosylab::acs::maci::manager::ManagerImpl::checkCyclicDependency(), com::cosylab::acs::maci::manager::ManagerImpl::clientLogin(), com::cosylab::acs::maci::manager::ManagerImpl::clientLogout(), com::cosylab::acs::maci::manager::ComponentInfoTopologicalSort::ComponentInfoTopologicalSort(), com::cosylab::acs::maci::manager::ComponentInfoTopologicalSortManager::ComponentInfoTopologicalSortManager(), com::cosylab::acs::maci::manager::ManagerImpl::containerInternalStateMerge(), com::cosylab::acs::maci::manager::ManagerImpl::containerLogin(), com::cosylab::acs::maci::manager::ManagerImpl::containerLogout(), com::cosylab::acs::maci::manager::ManagerImpl::doCycleCheck(), com::cosylab::acs::maci::manager::ManagerImpl::getAdministrators(), com::cosylab::acs::maci::manager::ManagerImpl::getClientInfo(), com::cosylab::acs::maci::manager::ManagerImpl::getCollocatedComponent(), com::cosylab::acs::maci::manager::ManagerImpl::getComponentInfo(), com::cosylab::acs::maci::manager::ManagerImpl::getComponentNonSticky(), com::cosylab::acs::maci::manager::ManagerImpl::getContainerInfo(), com::cosylab::acs::maci::manager::ManagerImpl::getContainersInfo(), com::cosylab::acs::maci::manager::ManagerImpl::getRequestorName(), com::cosylab::acs::maci::manager::ManagerImpl::initializePingTasks(), com::cosylab::acs::maci::manager::ManagerImpl::internalDeactivateComponent(), com::cosylab::acs::maci::manager::ManagerImpl::internalNoSyncReleaseComponent(), com::cosylab::acs::maci::manager::ManagerImpl::internalNoSyncRequestComponent(), com::cosylab::acs::maci::manager::ManagerImpl::internalNoSyncRestartComponent(), com::cosylab::acs::maci::manager::ManagerImpl::internalReleaseComponent(), com::cosylab::acs::maci::manager::ManagerImpl::internalRestartComponent(), com::cosylab::acs::maci::manager::ManagerImpl::logout(), com::cosylab::acs::maci::manager::ManagerImpl::makeComponentImmortal(), com::cosylab::acs::maci::manager::ComponentInfoTopologicalSort::markImmortalChain(), com::cosylab::acs::maci::manager::ManagerImpl::registerComponent(), com::cosylab::acs::maci::manager::ComponentInfoTopologicalSortManager::run(), com::cosylab::acs::maci::manager::ManagerImpl::securityCheck(), and com::cosylab::acs::maci::test::ManagerImplSerializationTest::testClientLogin().
| boolean com::cosylab::acs::maci::manager::HandleDataStore::isAllocated | ( | int | handle | ) | [inline] |
Determines whether a given handle is allocated.
| handle | the handle in question. |
true if an element with handle handle already exists in this ADT, false otherwise. References capacity(), elements, and com::cosylab::acs::maci::manager::HandleDataStore::Element::free.
Referenced by com::cosylab::acs::maci::manager::ManagerImpl::administratorLogout(), com::cosylab::acs::maci::test::HandleDataStoreTest::allocate(), com::cosylab::acs::maci::manager::ManagerImpl::clientLogout(), com::cosylab::acs::maci::manager::ManagerImpl::containerInternalStateMerge(), com::cosylab::acs::maci::manager::ManagerImpl::containerLogout(), com::cosylab::acs::maci::test::HandleDataStoreTest::deallocate(), com::cosylab::acs::maci::manager::ManagerImpl::getClientInfo(), com::cosylab::acs::maci::manager::ManagerImpl::getComponentInfo(), com::cosylab::acs::maci::manager::ManagerImpl::getContainerInfo(), com::cosylab::acs::maci::manager::ManagerImpl::getRequestorName(), com::cosylab::acs::maci::manager::ManagerImpl::internalNoSyncDeactivateComponent(), com::cosylab::acs::maci::manager::ManagerImpl::internalNoSyncReleaseComponent(), com::cosylab::acs::maci::manager::ManagerImpl::internalNoSyncRequestComponent(), com::cosylab::acs::maci::manager::ManagerImpl::internalNoSyncRestartComponent(), com::cosylab::acs::maci::manager::ManagerImpl::internalReleaseComponent(), com::cosylab::acs::maci::manager::ManagerImpl::internalRestartComponent(), com::cosylab::acs::maci::manager::ComponentInfoTopologicalSortManager::run(), com::cosylab::acs::maci::manager::ManagerImpl::securityCheck(), and com::cosylab::acs::maci::test::HandleDataStoreTest::testDefaultAllocation().
| boolean com::cosylab::acs::maci::manager::HandleDataStore::isEmpty | ( | ) | [inline] |
Tests if this list has no elements.
true if this list has no elements, false otherwise. References size().
| int com::cosylab::acs::maci::manager::HandleDataStore::last | ( | ) | [inline] |
Return the handle of the last element in this ADT.
Referenced by ackAllocation(), and deallocate().
| int com::cosylab::acs::maci::manager::HandleDataStore::next | ( | int | handle | ) | [inline] |
Return the handle of the next element in this ADT.
| handle | handle of the element whose sucessor's handle we wish to acquire. |
handle. If handle is the last element, 0 is returned. References elements, and com::cosylab::acs::maci::manager::HandleDataStore::Element::next.
Referenced by com::cosylab::acs::maci::manager::ManagerImpl::administratorLogin(), allocate(), com::cosylab::acs::maci::manager::ManagerImpl::checkCyclicDependency(), com::cosylab::acs::maci::manager::ManagerImpl::clientLogin(), com::cosylab::acs::maci::manager::ComponentInfoTopologicalSort::ComponentInfoTopologicalSort(), com::cosylab::acs::maci::manager::ComponentInfoTopologicalSortManager::ComponentInfoTopologicalSortManager(), com::cosylab::acs::maci::manager::ManagerImpl::containerInternalStateMerge(), com::cosylab::acs::maci::manager::ManagerImpl::containerLogin(), deallocate(), com::cosylab::acs::maci::manager::ManagerImpl::getAdministrators(), com::cosylab::acs::maci::manager::ManagerImpl::getClientInfo(), com::cosylab::acs::maci::manager::ManagerImpl::getCollocatedComponent(), com::cosylab::acs::maci::manager::ManagerImpl::getComponentInfo(), com::cosylab::acs::maci::manager::ManagerImpl::getComponentNonSticky(), com::cosylab::acs::maci::manager::ManagerImpl::getContainerInfo(), com::cosylab::acs::maci::manager::ManagerImpl::getContainersInfo(), com::cosylab::acs::maci::manager::ManagerImpl::initializePingTasks(), com::cosylab::acs::maci::manager::ManagerImpl::internalDeactivateComponent(), com::cosylab::acs::maci::manager::ManagerImpl::internalNoSyncRequestComponent(), com::cosylab::acs::maci::manager::ManagerImpl::internalReleaseComponent(), com::cosylab::acs::maci::manager::ManagerImpl::internalRestartComponent(), com::cosylab::acs::maci::manager::ManagerImpl::makeComponentImmortal(), com::cosylab::acs::maci::manager::ComponentInfoTopologicalSort::markImmortalChain(), preallocate(), com::cosylab::acs::maci::manager::ManagerImpl::registerComponent(), com::cosylab::acs::maci::test::HandleDataStoreTest::testDefaultAllocation(), com::cosylab::acs::maci::test::HandleDataStoreTest::testFreeAllocation(), and toString().
| int com::cosylab::acs::maci::manager::HandleDataStore::preallocate | ( | ) | [inline] |
Preallocate an element in this HandleDataStore.
0 References allocate(), elements, and next().
Referenced by com::cosylab::acs::maci::test::HandleDataStoreTest::testFreeAllocation().
| int com::cosylab::acs::maci::manager::HandleDataStore::previous | ( | int | handle | ) | [inline] |
Return the handle of the previous element in this ADT.
| handle | handle of the element whose predecessor's handle we wish to acquire. |
handle. If handle is the first element, 0 is returned. References elements, and com::cosylab::acs::maci::manager::HandleDataStore::Element::previous.
Referenced by deallocate(), and com::cosylab::acs::maci::test::HandleDataStoreTest::testDefaultAllocation().
| void com::cosylab::acs::maci::manager::HandleDataStore::set | ( | int | handle, | |
| Object | data | |||
| ) | [inline] |
Sets the element with the specified handle.
NOTE: handle is not checked, if it is valid.
| handle | handle of the element | |
| data | data to be set |
| IndexOutOfBoundsException | if handle is out of bounds. |
References com::cosylab::acs::maci::manager::HandleDataStore::Element::data, and elements.
| void com::cosylab::acs::maci::manager::HandleDataStore::setCapacity | ( | int | newCapacity | ) | [inline] |
Sets the capacity of this HandleDataStore instance to hold newCapacity elements;.
| newCapacity | the desired capacity. |
References capacity(), elements, com::cosylab::acs::maci::manager::HandleDataStore::Element::free, maxCapacity, com::cosylab::acs::maci::manager::HandleDataStore::Element::next, and com::cosylab::acs::maci::manager::HandleDataStore::Element::previous.
Referenced by allocate(), and HandleDataStore().
| int com::cosylab::acs::maci::manager::HandleDataStore::size | ( | ) | [inline] |
Returns the number of elements in this ADT.
Referenced by allocate(), deallocate(), isEmpty(), and toString().
| String com::cosylab::acs::maci::manager::HandleDataStore::toString | ( | ) | [inline] |
Returns a single-line rendition of this instance into text.
References capacity(), first(), next(), and size().
Capacity of this ADT.
final int com::cosylab::acs::maci::manager::HandleDataStore::DEFAULT_MAX_CAPACITY = Integer.MAX_VALUE [static] |
Default maximum capacity of this ADT.
Referenced by HandleDataStore().
Array of elements
Referenced by ackAllocation(), allocate(), deallocate(), get(), isAllocated(), next(), preallocate(), previous(), set(), and setCapacity().
int com::cosylab::acs::maci::manager::HandleDataStore::first [private] |
Handle of the first non-free element.
Referenced by com::cosylab::acs::maci::manager::ManagerImpl::administratorLogin(), com::cosylab::acs::maci::manager::ManagerImpl::checkCyclicDependency(), com::cosylab::acs::maci::manager::ManagerImpl::clientLogin(), com::cosylab::acs::maci::manager::ComponentInfoTopologicalSort::ComponentInfoTopologicalSort(), com::cosylab::acs::maci::manager::ComponentInfoTopologicalSortManager::ComponentInfoTopologicalSortManager(), com::cosylab::acs::maci::manager::ManagerImpl::containerInternalStateMerge(), com::cosylab::acs::maci::manager::ManagerImpl::containerLogin(), com::cosylab::acs::maci::manager::ManagerImpl::getAdministrators(), com::cosylab::acs::maci::manager::ManagerImpl::getClientInfo(), com::cosylab::acs::maci::manager::ManagerImpl::getCollocatedComponent(), com::cosylab::acs::maci::manager::ManagerImpl::getComponentInfo(), com::cosylab::acs::maci::manager::ManagerImpl::getComponentNonSticky(), com::cosylab::acs::maci::manager::ManagerImpl::getContainerInfo(), com::cosylab::acs::maci::manager::ManagerImpl::getContainersInfo(), com::cosylab::acs::maci::manager::ManagerImpl::initializePingTasks(), com::cosylab::acs::maci::manager::ManagerImpl::internalDeactivateComponent(), com::cosylab::acs::maci::manager::ManagerImpl::internalNoSyncRequestComponent(), com::cosylab::acs::maci::manager::ManagerImpl::internalReleaseComponent(), com::cosylab::acs::maci::manager::ManagerImpl::internalRestartComponent(), com::cosylab::acs::maci::manager::ManagerImpl::makeComponentImmortal(), com::cosylab::acs::maci::manager::ComponentInfoTopologicalSort::markImmortalChain(), com::cosylab::acs::maci::manager::ManagerImpl::registerComponent(), com::cosylab::acs::maci::test::ManagerImplSerializationTest::testClientDie(), com::cosylab::acs::maci::test::ManagerImplSerializationTest::testClientLogin(), com::cosylab::acs::maci::test::ManagerImplSerializationTest::testContainerDie(), com::cosylab::acs::maci::test::HandleDataStoreTest::testDefaultAllocation(), and com::cosylab::acs::maci::test::HandleDataStoreTest::testFreeAllocation().
int com::cosylab::acs::maci::manager::HandleDataStore::last [private] |
Handle of the last non-free element.
Referenced by com::cosylab::acs::maci::test::HandleDataStoreTest::testDefaultAllocation().
Maximum capacity of this ADT.
Referenced by allocate(), and setCapacity().
final long com::cosylab::acs::maci::manager::HandleDataStore::serialVersionUID = -6137572272422678754L [static, private] |
Serial version UID.
int com::cosylab::acs::maci::manager::HandleDataStore::size [private] |
Number of elements currently in the HandleDataStore.
Referenced by com::cosylab::acs::maci::manager::ComponentInfoTopologicalSort::ComponentInfoTopologicalSort(), com::cosylab::acs::maci::manager::ManagerImpl::getAdministrators(), com::cosylab::acs::maci::manager::ManagerImpl::getContainersInfo(), and com::cosylab::acs::maci::test::HandleDataStoreTest::testDefaultAllocation().
1.6.2