Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'Byte Array 2GB limit workaround
- Public Structure StorageArray
- Private MGR As List(Of Byte())
- Private Tail() As Byte
- Private WholeElements As Integer
- Private _Length As Long
- Public ReadOnly Property Length() As Long
- Get
- Return _Length
- End Get
- End Property
- Public Sub New(ByVal size As Long)
- _Length = size + 1
- Dim cnt As Long = Math.Ceiling(_Length / 2147483591)
- Dim rmd As Integer = _Length Mod 2147483591
- If cnt <= 1 Then
- Tail = New Byte(size) {}
- Else
- WholeElements = cnt - 1
- MGR = New List(Of Byte())
- For i = 1 To WholeElements
- MGR.Add(New Byte(2147483590) {})
- Next
- If rmd > 0 Then Tail = New Byte(rmd - 1) {}
- End If
- End Sub
- Default Public Property Bytes(ByVal index As Long) As Byte
- Get
- index += 1
- Dim cnt As Integer = Math.Ceiling(index / 2147483591) - 1
- Dim rmd As Integer = (index Mod 2147483591) - 1
- If rmd < 0 Then rmd = 0
- If cnt >= WholeElements Then Return Tail(rmd) Else Return MGR(cnt)(rmd)
- End Get
- Set(value As Byte)
- index += 1
- Dim cnt As Integer = Math.Ceiling(index / 2147483591) - 1
- Dim rmd As Integer = (index Mod 2147483591) - 1
- If rmd < 0 Then rmd = 0
- If cnt >= WholeElements Then Tail(rmd) = value Else MGR(cnt)(rmd) = value
- End Set
- End Property
- End Structure
Advertisement
Add Comment
Please, Sign In to add comment