Description | Hierarchy | Fields | Methods | Properties |
type unaList = class(unaObject)
This is general purpose list of items. Multi-threaded safe.
constructor create(dataType: unaListDataType = uldt_ptr; sorted: bool = false); |
|
function add(item: int32): int; overload; |
|
function add(item: pointer): int; overload; |
|
function add(item: int64): int; overload; |
|
function assign(list: unaList): int; |
|
function asString(const delimiter: string; treatAsSigned: bool = true; base: unsigned = 10): string; |
|
function checkDataEvent(): bool; |
|
function copyFrom(list: pointer; listSize: int = -1; copyOperation: unaListCopyOpEnum = unaco_add; startIndex: int = 0): int; overload; |
|
function copyFrom(list: unaList; copyOperation: unaListCopyOpEnum = unaco_add; startIndex: int = 0): int; overload; |
|
function copyTo(out list: pointer; includeZeroIndexCount: bool): int; |
|
function get(index: int): pointer; |
|
function getObject(index: int): tObject; |
|
function indexOf(item: int32): int; overload; |
|
function indexOf(item: pointer): int; overload; |
|
function indexOf(item: int64): int; overload; |
|
function insert(index: int; item: pointer): int; overload; |
|
function insert(index: int; item: int32): int; overload; |
|
function insert(index: int; item: int64): int; overload; |
|
function lock(ro: bool; timeout: tTimeout = 100 ): bool; |
|
function lockObject(index: int; ro: bool = true; timeout: tTimeout = 1000): unaObject; |
|
function removeByIndex(index: int; doFree: unsigned = 2): bool; overload; |
|
function removeFromEdge(removeFromBegining: bool = true): bool; |
|
function removeItem(item: pointer; doFree: unsigned = 2): bool; overload; |
|
function removeItem(item: int64): bool; overload; |
|
function removeItem(item: int32): bool; overload; |
|
function setItem(itemToReplace: pointer; newItem: pointer; doFree: unsigned = 2): unsigned; overload; |
|
function sort(): bool; |
|
function waitForData(timeout: tTimeout = 100): bool; |
|
function compare(a, b: pointer): int; virtual; |
|
function doAdd(item: pointer): int; overload; virtual; |
|
function doCopyFrom(list: pointer; listSize: int = -1; copyOperation: unaListCopyOpEnum = unaco_add; startIndex: int = 0): int; virtual; |
|
function doInsert(index: int; item: pointer; brokeSorted: bool = true): int; virtual; |
|
function isEmpty(): bool; |
|
function mapDoFree(doFree: unsigned): bool; |
|
procedure BeforeDestruction(); override; |
|
procedure clear(doFree: unsigned = 2; force: bool = false); |
|
procedure reverse(); |
|
procedure setCapacity(value: unsigned); |
|
procedure setItem(index: int; item: int32); overload; |
|
procedure setItem(index: int; item: pointer; doFree: unsigned = 2); overload; |
|
procedure setItem(index: int; item: int64); overload; |
|
procedure unlockRO(); |
|
procedure unlockWO(); |
|
procedure doReverse(); virtual; |
|
procedure doSetCapacity(value: unsigned; force: bool = false); virtual; |
|
procedure doSetItem(index: int; item: pointer; brokeSorted: bool = true; doFree: unsigned = 2); overload; virtual; |
|
procedure notifyBeforeRemove(index: int); virtual; |
|
procedure releaseItem(index: int; doFree: unsigned); virtual; |
property autoFree: bool read f_autoFree write f_autoFree; |
|
property count: int read f_count; |
|
property dataItemSize: int read f_dataItemSize; |
|
property dataType: unaListDataType read getDT; |
|
property item[index:int]: pointer read get write internalSetItem; |
|
property list: unaListStorage read f_list; |
|
property listPtr: pointer read getListPtr; |
|
property listPtrAt[index:int]: pointer read getListPtrAt; |
|
property onItemBeforeRemove: unaListOnItemBeforeRemoveEvent read f_onItemBeforeRemove write f_onItemBeforeRemove; |
|
property onItemRelease: unaListOnItemReleaseEvent read f_onItemRelease write f_onItemRelease; |
|
property singleThreaded: bool read f_singleThreaded write f_singleThreaded; |
|
property sorted: bool read f_sorted; |
|
property timeout: tTimeout read f_timeout write f_timeout default 1000; |
constructor create(dataType: unaListDataType = uldt_ptr; sorted: bool = false); |
|
NOTE: default value for dataType is now uldt_ptr! |
function add(item: int32): int; overload; |
|
Adds item to the end of the list. Returns list index of inserted item (usually count - 1). |
function add(item: pointer): int; overload; |
|
function add(item: int64): int; overload; |
|
function assign(list: unaList): int; |
|
Returns number of items copied. |
function asString(const delimiter: string; treatAsSigned: bool = true; base: unsigned = 10): string; |
|
function checkDataEvent(): bool; |
|
function copyFrom(list: pointer; listSize: int = -1; copyOperation: unaListCopyOpEnum = unaco_add; startIndex: int = 0): int; overload; |
|
Returns number of items processed. If listSize is -1 list has "zero index count", i.e. number of items is stored as first item of the list. |
function copyFrom(list: unaList; copyOperation: unaListCopyOpEnum = unaco_add; startIndex: int = 0): int; overload; |
|
function copyTo(out list: pointer; includeZeroIndexCount: bool): int; |
|
Creates a array and copies list items into it. If includeZeroIndexCount is true, the first elemet of array will contain number of items in it. Returnssize of created array (in bytes). |
function get(index: int): pointer; |
|
Returns item from the list. index specifies the index of item to be returned. |
function getObject(index: int): tObject; |
|
Returns item with specified index as object. |
function indexOf(item: int32): int; overload; |
|
Searches the list for specified item value. Returns -1 if no item was found. |
function indexOf(item: pointer): int; overload; |
|
function indexOf(item: int64): int; overload; |
|
function insert(index: int; item: pointer): int; overload; |
|
function insert(index: int; item: int32): int; overload; |
|
Inserts an item at specified position (index parameter) in the list. Does nothing if index is bigger than count. Returns index. |
function insert(index: int; item: int64): int; overload; |
|
function lock(ro: bool; timeout: tTimeout = 100 ): bool; |
|
Locks the list for read-only (RO) or write-only (WO) access.
Parameters
Returnsfalse if lock cannot be set in a timeout period |
function lockObject(index: int; ro: bool = true; timeout: tTimeout = 1000): unaObject; |
|
Locks an object in the list. Don't forget to release the object. Returnsnil if object was not found or was not locked. |
function removeByIndex(index: int; doFree: unsigned = 2): bool; overload; |
|
Removes item with specified index from the list. Returns true if item was removed, or false otherwise. |
function removeFromEdge(removeFromBegining: bool = true): bool; |
|
Removes first (removeFirst = true) or last (removeFirst = false) item from the list (if it presents). Returns true if item was removed, or false otherwise. |
function removeItem(item: pointer; doFree: unsigned = 2): bool; overload; |
|
function removeItem(item: int64): bool; overload; |
|
function removeItem(item: int32): bool; overload; |
|
Removes specifed item from the list. Returns true if item was removed, or false otherwise. |
function setItem(itemToReplace: pointer; newItem: pointer; doFree: unsigned = 2): unsigned; overload; |
|
function sort(): bool; |
|
Sorts the list. Override compare() method for custom sorting. By default list knows how to sort int32, int64 and string values. |
function waitForData(timeout: tTimeout = 100): bool; |
|
function compare(a, b: pointer): int; virtual; |
|
Should return -1 if a < b, +1 if a > b and 0 otherwise. |
function doAdd(item: pointer): int; overload; virtual; |
|
function doCopyFrom(list: pointer; listSize: int = -1; copyOperation: unaListCopyOpEnum = unaco_add; startIndex: int = 0): int; virtual; |
|
function doInsert(index: int; item: pointer; brokeSorted: bool = true): int; virtual; |
|
function isEmpty(): bool; |
|
Returns true if there are no items in the list. Note, that due to multi-threading issues returned result may be not accurate. Use for quick checks only, like status update. |
function mapDoFree(doFree: unsigned): bool; |
|
procedure BeforeDestruction(); override; |
|
procedure clear(doFree: unsigned = 2; force: bool = false); |
|
Clears the list. All items will be removed and count will be reset to 0. |
procedure reverse(); |
|
Reverses items in the list. |
procedure setCapacity(value: unsigned); |
|
Allocates resources for new capacity. |
procedure setItem(index: int; item: int32); overload; |
|
Sets item value in the list. index specifies the index of item to be set. item is value of item. Old item will be freed. If old item is object, doFree parameter specifies the action should be taken. |
procedure setItem(index: int; item: pointer; doFree: unsigned = 2); overload; |
|
procedure setItem(index: int; item: int64); overload; |
|
procedure unlockRO(); |
|
Unlocks the list after read-only lock. Must be called after each successful lock(true) |
procedure unlockWO(); |
|
Unlocks the list after write-only lock. Must be called after each successful lock(false) |
procedure doReverse(); virtual; |
|
procedure doSetCapacity(value: unsigned; force: bool = false); virtual; |
|
procedure doSetItem(index: int; item: pointer; brokeSorted: bool = true; doFree: unsigned = 2); overload; virtual; |
|
procedure notifyBeforeRemove(index: int); virtual; |
|
procedure releaseItem(index: int; doFree: unsigned); virtual; |
|
Disposes the item. |
property autoFree: bool read f_autoFree write f_autoFree; |
|
Set this property to true for lists which know how to free own items, to allow items to be freed by the list. |
property count: int read f_count; |
|
Number of items in the list. |
property dataItemSize: int read f_dataItemSize; |
|
property dataType: unaListDataType read getDT; |
|
property item[index:int]: pointer read get write internalSetItem; |
|
Returns list item by it index. |
property list: unaListStorage read f_list; |
|
property listPtr: pointer read getListPtr; |
|
property listPtrAt[index:int]: pointer read getListPtrAt; |
|
property onItemBeforeRemove: unaListOnItemBeforeRemoveEvent read f_onItemBeforeRemove write f_onItemBeforeRemove; |
|
Fires when list item is about to be removed from the list. |
property onItemRelease: unaListOnItemReleaseEvent read f_onItemRelease write f_onItemRelease; |
|
Fires when list item is needed to be released. NOTE: item[index] could be nil. |
property singleThreaded: bool read f_singleThreaded write f_singleThreaded; |
|
When this property is true list will not use gate to protect internal data in multi-threading access. This may increase performance a little. |
property sorted: bool read f_sorted; |
|
property timeout: tTimeout read f_timeout write f_timeout default 1000; |
|
Default timeout. |
(c) 2012 Lake of Soft