Queue is a FIFO collection. You can add elements to the end of the queue and get the first item.
Access the first item with Queue.FirstItem.
Example:
V1.10 released with a new AddBytesToLastItem method. This is a very useful method which allows building an item with multiple calls instead of using JoinBytes or JoinStrings which require more memory.
Access the first item with Queue.FirstItem.
Example:
B4X:
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
Queue.AddBytes("Item 1")
Queue.AddBytes("Item 222")
Queue.AddBytes("Item 3333")
Queue.AddBytes("Item 44")
Queue.AddBytes("Item 555555")
Queue.RemoveFirst
Queue.AddBytes("Item 612312")
Queue.AddBytes("Item 77777777777")
Queue.AddBytes("Item 88")
Queue.AddBytes("Item 99")
Dim str() As Byte = "Item #"
For i = 1 To 10
Queue.AddBytes(str)
Queue.AddBytesToLastItem(NumberFormat(i, 0, 0))
Next
Do While Queue.Size > 0
Log(Queue.FirstItem)
Queue.RemoveFirst
Loop
Log("Size: ", Queue.Size)
End Sub
V1.10 released with a new AddBytesToLastItem method. This is a very useful method which allows building an item with multiple calls instead of using JoinBytes or JoinStrings which require more memory.
Attachments
Last edited: