RakuArrayTable.cls

VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "RakuArrayTable"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Private list As Collection
Private CurrentList As Collection


Public Sub Class_Initialize()
    Set list = New Collection
    
End Sub


Public Sub addColumn(obj As Variant)
    list(list.Count).Add obj
End Sub


Public Sub AddRow(Optional ByVal obj As Variant)
    
    If IsMissing(obj) Then
        list.Add New Collection
    Else
        list.Add obj
    End If
    Set CurrentList = list(list.Count)
End Sub


Public Sub clear()
    Set list = Nothing
    Set CurrentList = Nothing
    Set list = New Collection
End Sub


Public Sub Concat(table As RakuArrayTable)
    For r = 1 To table.Nrows
        AddRow
        For c = 1 To table.Ncolumns
            addColumn table.Cell(r, c)
        Next c
    Next r
End Sub


Public Property Get Cell(ROW, col)
    Cell = list(ROW)(col)
End Property


Public Property Get CurrentRecord()
    CurrentRecord = ToArray(CurrentList)
End Property


Private Function ToArr(l As Collection)
    Dim Result As Variant
    ReDim Result(1 To l.Count)
    For i = 1 To l.Count
        Result(i) = l(i)
    Next
    ToArr = Result
End Function


Public Property Get Nrows()
    Nrows = list.Count
End Property


Public Property Get Ncolumns()
    Ncolumns = CurrentList.Count
End Property


Public Property Get columns(col)
    Dim Result
    ReDim Result(1 To list.Count)
    For i = 1 To list.Count
        Result(i) = list(i)(col)
    Next
    columns = Result
End Property


Public Function hasItemCurrentRow(item)
    For Each c In CurrentList
        If c = item Then
            hasItemCurrentRow = True
            Exit Function
        End If
    Next
    hasItemCurrentRow = False
End Function


Public Property Get rows(ROW)
    rows = ToArr(list(ROW))
End Property


Public Property Get ToArray()
    Dim Result As Variant
    ReDim Result(1 To Nrows, 1 To Ncolumns)
    For i = 1 To Nrows
        For j = 1 To Ncolumns
            Result(i, j) = rows(i)(j)
        Next j
    Next i
    ToArray = Result
End Property

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值