- Joined
- Nov 30, 2007
- Messages
- 1,202
Lets say I'm indexing shit 0, 1, 2, 4, 5 ... but when I reach a cap I want to keep the order intact but remove the first one added... How do I accomplish this with out reshuffling everything?
Some of you will say linked list. Yes. But I don't only need to loop from start to finish. I also need to have a function that allows me to print a string stored in list(X) [Xth position from "start"]. After stuff have been added and removed by the FIFO principle.
Basically I want the LIST to continue adding stuff even after OP LIMIT is reached by removing the first elements. But retaining the order and all that. Without having to reshuffle it every time...
---
- Store 5 strings in a struct. (5 is a arbitrary number for testing purposes)
- When you add a string they are stored in order, 0, 1 2, 3, 4, when you reach 5, [0] is removed and 5 is added to it's place.
- Must be able to loop from array [1] to array [0] in this above state in the order they were added. (1, 2, 3, 4, 5 "[0]")
- Must be able to retrieve the current index X from last added.
Some of you will say linked list. Yes. But I don't only need to loop from start to finish. I also need to have a function that allows me to print a string stored in list(X) [Xth position from "start"]. After stuff have been added and removed by the FIFO principle.
Basically I want the LIST to continue adding stuff even after OP LIMIT is reached by removing the first elements. But retaining the order and all that. Without having to reshuffle it every time...
---
- Store 5 strings in a struct. (5 is a arbitrary number for testing purposes)
- When you add a string they are stored in order, 0, 1 2, 3, 4, when you reach 5, [0] is removed and 5 is added to it's place.
- Must be able to loop from array [1] to array [0] in this above state in the order they were added. (1, 2, 3, 4, 5 "[0]")
- Must be able to retrieve the current index X from last added.
Last edited: