I didn't know what else to call this. You basically push items to it and it and the newest one will be on top. It has a fixed size though so everything that's pushed out will be lost.
Strict
Class Feed<T>
Method New(size:Int)
data = New T[size]
End
Method Push:Void(val:T)
For Local i:Int = count To 1 Step -1
data[i] = data[i-1]
Next
data[0] = val
count += 1
count = Min(count, data.Length-1)
End
Method Get:T(i:Int)
Return data[i]
End
Method Length:Int() Property
Return count+1
End
Private
Field data:T[]
Field count:Int
End
I use it for a debug overlay where I constantly push variables that change over time (position, etc.). For drawing just loop through it like you would with a monkey stack.
|