ADD | Add new element to sorted array. |
DEL | Removes some data from SORTEDARRAY. |
DELITEM | Delete element from sorted array by index. |
GETDATA | Get element data by index in sorted array. |
GETFIRST | Get first item data are sorted array. |
GETITEM | Get item are sorted array by index. |
GETKEY | Get element keys by index in sorted array. |
GETLAST | Get last item data are sorted array. |
HARDSEEK | Hard seek element in sorted array. |
LEN | Returns count items into SORTEDARRAY. |
SEEK | Seek element in sorted array. |
SOFTSEEK | Soft seek element in sorted array. |
TSORTEDARRAYNEW | SORTEDARRAY constructor. |
Add(<nKey>, <Value>) --> .T./.F.
Add() is added new item to class SortedArray with key <nKey> and value <Value>. Every item of sorted array is array containes only two elements: key (<nKey>) and value (<Value>). Items with low keys <nKey> are sorted toward the top of the array. If <nKey> or <Value> not specified then attribute <Error> will be contain error description.
You can add several items with identical keys. In this case class SortedArray will contain all these items and item can be inserted at suitable place.
Del(<nKey>, <Value>) --> .T. || .F. Delete(<nKey>, <Value>) --> .T. || .F. DelKey(<nKey>, <Value>) --> .T. || .F.
Del(), Delete(), DelKey() is deleted item from sorted array by key and value.
If parameters <nKey> or <Value> not spacified then methods returns FALSE and write error description to attribute <Error>.
When element with <nKey> and <Value> not found methods returns FALSE and write error description to attribute <Error>.
DelItem(<nPos>) --> .T. || .F.
DelItem() is removed item from sorted array by index and returns TRUE.
If <nPos> without of bound sorted array then method return FALSE and write to attribute <Error> error descriptions.
GetData(<nPos>) --> data
GetData() gets data value by item index in sorted array and returns it if found, otherwise it returns NIL. If index is without of bound sorted array or is NIL then attribute <Error> to be keep error description.
GetFirst() --> data value
GetFirst() gets data value first items sorted array and returns it.
If no items in sorted array it returns NIL.
GetItem(<nPos>) --> aItem
GetItem() gets key value and data value by item index in sorted array and returns array containes it. In other case it returns NIL. If index is without of bound sorted array or is NIL then attribute <Error> to be keep error description.
GetKey(<nPos>) --> nKeyValue
GetKey() gets key value by item index in sorted array and returns it if found, otherwise it returns NIL. If index is without of bound sorted array or is NIL then attribute <Error> to be keep error description.
GetLast() --> data value
GetLast() gets data value last added items in to sorted array and returns it. If no items in sorted array it returns NIL.
HardSeek(<nKey>) --> nPos
HardSeek() calls method Seek() as Seek(<nKey>, .F.)
Len() --> nCount
Len() is returned sorted array length what equal lenght of <Items>.
If sorted array is empty, then method returns zero.
Seek(<nKey>[, <lSoft>]) --> nPos
Seek() moves to the first item whose key is equal to <nKey>. If such a item is found, it becomes to current item and Seek() returns item index in sorted array, attribute <Found> sets to TRUE, otherwise it returns Len() +1 position and attribute <Found> sets to FALSE The positioning in sorted array is as followes: for normal (hard) seek (lSoft is .F.), the sorted array is positioned to Len() + 1; for a soft seek, the sorted array positioned to the first item whose key value is greather than specified key <nKey>. If no such item exist, the sorted array positioned to Len()+1 and returns Len() + 1 and sets attribute <Found> sets to FALSE.
<nKey> | Numeric, a specified key value that you search. |
<lSoft> | Logical, is an optional logical value that specifies whether a soft seek is to be perfomed. This determines how the sorted array is positioned if the specified key not found. By default <lSoft> is .F. |
Returns : | Is returns item index whose key value is equal <nKey> if specified key value was found, otherwise it returns Len()+1. |
SoftSeek(<nKey>) --> nPos
SoftSeek() calls method Seek() as Seek(<nKey>, .T.)