dynamic LONG array lite object (not OOP object)
ReDim automatic
ONE based index
array referenced with LONG handle (UDT, ... etc)
array may be stored/restored to string


Code:
 
 
'pbcc 5, pbwin 9  (pb 4/8 ok)
    'dynamic LONG array lite object (not OOP object)
    '   ReDim automatic
    '   ONE based index
    'array referenced with LONG handle
    '
    'array may be stored/restored to string
 
 
Declare Function LArr_Alloc Lib "LArr_DLL-1.dll" () As Long
    'create new array object
    'return handle
    '   null if fail

Declare Sub LArr_Free Lib "LArr_DLL-1.dll" (ByVal arr As Long)
    'close array object
    'free resources

Declare Sub LArr_Clear Lib "LArr_DLL-1.dll" (ByVal arr As Long)
    'delete all data

Declare Function LArr_Count Lib "LArr_DLL-1.dll" (ByVal arr As Long) As Long
    'get stored element count

Declare Sub LArr_ReDim Lib "LArr_DLL-1.dll" (ByVal arr As Long, ByVal Count As Long)
    'ReDim array - data preserved

Declare Sub LArr_Add Lib "LArr_DLL-1.dll" (ByVal arr As Long, ByVal item As Long)
    'append value
    'redim automatic

Declare Sub LArr_Insert Lib "LArr_DLL-1.dll" (ByVal arr As Long, ByVal index As Long, ByVal item As Long)
    'insert value at index
    'redim automatic
    '   if index > array then item appended

Declare Sub LArr_Delete Lib "LArr_DLL-1.dll" (ByVal arr As Long, ByVal index As Long)
    'delete array element at index
    'redim automatic

Declare Sub LArr_Set Lib "LArr_DLL-1.dll" (ByVal arr As Long, ByVal index As Long, ByVal item As Long)
    'store item at index

Declare Function LArr_Get Lib "LArr_DLL-1.dll" (ByVal arr As Long, ByVal index As Long) As Long
    'get item at index

Declare Function LArr_BinFind Lib "LArr_DLL-1.dll" (ByVal arr As Long, ByVal item As Long) As Long
    'binary search for "item"
    '   return index if found
    '   zero if not found

Declare Function LArr_BinFindPosition Lib "LArr_DLL-1.dll" (ByVal arr As Long, ByVal item As Long) As Long
    'binary search for the position where "item" is, or should be
    '   zero if fail

Declare Function LArr_BinInsert Lib "LArr_DLL-1.dll" (ByVal arr As Long, ByVal item As Long) As Long
    'binary insert item
    '   array must sorted
    'return index
    '   zero if fail

Declare Sub LArr_BinSort Lib "LArr_DLL-1.dll" (ByVal arr As Long)
    'sort array
    '   (slow sort)

Declare Function LArr_BinFindUsing Lib "LArr_DLL-1.dll" (ByVal arr As Long, ByVal item As Long, ByVal doCompare As Dword) As Long
    'binary search for "item"
    '   return index if found
    '   zero if not found
    '
    'use external function to do comparison
    '   template: LArr_DoCompare(ByVal a As Long, ByVal b As Long)
    '       a = b | function = 0
    '       a < b | function < 0
    '       a > b | function > 0

Declare Function LArr_BinFindPositionUsing Lib "LArr_DLL-1.dll" (ByVal arr As Long, ByVal item As Long, ByVal doCompare As Dword) As Long
    'binary search for the position where "item" is, or should be
    '   zero if fail
    '
    'use external function to do comparison
    '   template: LArr_DoCompare(ByVal a As Long, ByVal b As Long)
    '       a = b | function = 0
    '       a < b | function < 0
    '       a > b | function > 0

Declare Function LArr_BinInsertUsing Lib "LArr_DLL-1.dll" (ByVal arr As Long, ByVal item As Long, ByVal doCompare As Dword) As Long
    'binary insert item
    '   array must sorted
    'return index
    '   zero if fail
    '
    'use external function to do comparison
    '   template: LArr_DoCompare(ByVal a As Long, ByVal b As Long)
    '       a = b | function = 0
    '       a < b | function < 0
    '       a > b | function > 0

Declare Sub LArr_BinSortUsing Lib "LArr_DLL-1.dll" (ByVal arr As Long, ByVal doCompare As Dword)
    'sort array
    '   (slow sort)
     '
    'use external function to do comparison
    '   template: LArr_DoCompare(ByVal a As Long, ByVal b As Long)
    '       a = b | function = 0
    '       a < b | function < 0
    '       a > b | function > 0

Declare Function LArr_Store Lib "LArr_DLL-1.dll" (ByVal arr As Long) As String
    'store array in string

Declare Function LArr_StoreValidate Lib "LArr_DLL-1.dll" (ByRef storedArr As String) As Long
    'validate storage string
    '   string has front and back DWord validation hash cookies

Declare Sub LArr_Restore Lib "LArr_DLL-1.dll" (ByVal arr As Long, ByRef storedArr As String)
    'restore array from string made with: LArr_Store()
    '   current contents of array will be lost
Attached Files