Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

LONG: Jagged and Two Dim Array (DLL & Class)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • LONG: Jagged and Two Dim Array (DLL & Class)

    -------------------------------------------------------------------
    DLL pb 4/8 ok
    Class requires 5/9
    NOTE: separate INC files in DLLs
    free: use at your own risk

    'dynamic LONG Jagged array
    ' ReDim automatic
    ' ONE based index
    'array referenced with LONG handle
    '
    'all indexes Row/Column order
    '
    ' array rows = 1 to LJag_RowCount(h)
    ' a row's column dimension may vary on each row
    ' 1 to LJag_ColCount(h, rowNo)
    '
    ' rows may be ReDim() - data preserved
    ' a row's columns may be ReDim() - data preserved
    '
    ' new rows may be inserted front, back, middle
    ' each new row will have zero columns until data added or LJag_ColReDim()
    '
    'array may be stored/restored to string
    -------------------------------------------------------------------
    'dynamic LONG - two dimension array
    ' ONE based index
    ' ReDim automatic (data preserved)
    ' ReDim rows & columns
    'array referenced with LONG handle
    '
    'all indexes Row/Column order
    '
    ' arrays automatically grow/shrink on row/column insert/delete
    '
    ' rows may be inserted (or added) anywhere in array array
    ' columns may be inserted (or added) anywhere in array array
    '
    'array may be stored/restored to string
    -------------------------------------------------------------------

    Code:
     
     
    'pbcc 5, pbwin 9
        'dynamic LONG Jagged array class
        '   ReDim automatic
        '   ONE based index
        '
        'all indexes Row/Column order
        '
        '   array rows = 1 to RowCount(h)
        '       a row's column dimension may vary on each row
        '           1 to ColCount(h, rowNo)
        '
        '   rows may be ReDim() - data preserved
        '       a row's columns may be ReDim() - data preserved
        '
        '   new rows may be inserted front, back, middle
        '       each new row will have zero columns until data added or ColReDim()
        '
        'array may be stored/restored to string
        '
        'implementation:
        '   LArr array holding LArr handles
        '
        'use:
        'put "LJagC_DLL-1.inc" in same folder as source code
        '#Include Once "LJagC_DLL-1.inc"
        '
        'put "LJagC_DLL-1.DLL" in same folder as source code
        '
        'LOCAL arr as LJagI
        'arr = NewCom ClsId $LJagC_GUID Lib "LJagC_DLL-1.DLL"
        '   start using
     
    $LJagC_GUID = Guid$("{FDEAD5E3-3E4F-483B-8DF2-0EC3A87F0292}")
    $LJagI_GUID = Guid$("{74992539-7E6B-47EF-A0AF-EBC1FF74165C}")
     
    Interface LJagI $LJagI_GUID
        Inherit IUnknown
        Method Clear()
            'delete all data
            '   call Clear() before obj = NOTHING
            '   internal resources will immediately be freed
            '       instead of waiting till obj destroyed
     
        Method RowCount() As Long
            'get number or rows in array
     
        Method ColCount(ByVal rowNo As Long) As Long
            'get number of columns on a particular row
     
        Method RowReDim(ByVal Count As Long)
            'ReDim rows in array - data preserved
     
        Method ColReDim(ByVal rowNo As Long, ByVal Count As Long)
            'ReDim number of columns on a particular row
     
        Method RowAdd()
            'appends blank row to rows (added row has no columns)
     
        Method ColAdd(ByVal rowNo As Long, ByVal item As Long)
            'add column to row and set value
     
        Method RowInsert(ByVal rowNo As Long)
            'insert empty row before rowNo - (new row has no columns)
     
        Method ColInsert(ByVal rowNo As Long, ByVal colNo As Long, ByVal item As Long)
            'insert item at rowNo/colNo
     
        Method RowDelete(ByVal rowNo As Long)
            'remove row (and its columns) from array
     
        Method ColDelete(ByVal rowNo As Long, ByVal colNo As Long)
            'delete column in row
     
        Property Get Item(ByVal rowNo As Long, ByVal colNo As Long) As Long
            'get item at row/col
     
        Property Set Item(ByVal rowNo As Long, ByVal colNo As Long, ByVal item As Long)
            'set item at row/col
     
        Method ColBinFind(ByVal rowNo As Long, ByVal item As Long) As Long
            'binary find item at rowNo
            '   column items MUST be sorted
            '   return colNo
            '   zreo if not found
     
        Method ColBinInsert(ByVal rowNo As Long, ByVal item As Long) As Long
            'binary insert item at rowNo
            '   row's columns MUST be sorted
            'return colNo / zero if fail
     
        Method ColBinSort(ByVal rowNo As Long)
            'sort items on a particular row
     
        Method Store() As String
            'store array in string
     
        Method Restore(ByVal storedArr As String)
            'rebuild array from storage string
            '   current contents cleared
     
        Method StoreValidate(ByVal storedArr As String) As Long
            'True/False if string is valid
            '   storage strings protected with two unique DWord validation hashes - front/back
     
    End Interface
    Attached Files
    stanthemanstan~gmail
    Dead Theory Walking
    Range Trie Tree
    HLib ~ Free Data Container Lib ~ Arrays, Lists, Stacks, Queues, Deques, Trees, Hashes
Working...
X