Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

buffer

Status
Not open for further replies.

knarfo

Programmer
Nov 21, 2006
8
NL
hello,
I would like to create buffer like the queue but then with a fixed length.
So when the last value is added then the first added value drops out:

position value
1 50
2 35
3 87

then value 29 is added and value 87 drops off:
position value
1 29
2 50
3 35



Does anybody know how to do that?

thanks
frank

 
For last in first out, you can use a Stack object. However, I don't think you can set a fixed capacity with stack. You could easily create your own class to maintain an internal ArrayList with a fixed capacity and return the Last item in the list.
 
Queue is first in, first out. I think he wants last in, first out.
 
HI,
The queue doesn't have a fixed length.
My buffer example has a fixed length of 3 positions.
I guess i'll use queue and when the length is 4 i'll degueue
one time. That makes the lenght 3 again.

I was hoping there would be a similar thing as stack or queue.

frank
 
yes the queue has a fixed length.

Code:
Dim q As New Queue(3)


Christiaan Baes
Belgium

My Blog
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top