Now, i‘m not really looking for an alternative for a circular array, But for a System that works similar to it.
A circular array is basically a normal array, that works like [i%array.length] (if i got that right…). What that means is, it repeats itself indefenitely(literally, without becoming bigger, since it just calculates the index to be „resized“. So if it has a length of 10 and you look for Index 103, it will give Index 3).
But what i‘m looking for is an array that works similar, But not quite. What i Need is a fast way to indefinetly run through a Single array and once i got to an Element and worked with it, delete it and set a new one to the end of the array.
Like stacking blocks, Taking the bottommost and putting it on top, after changing it, or Playing with it, then the Rest falls down, and you restart at the bottom(best example i had, Hope it explains it).
Now, Although a circular array Would work for the take bottommost and then go to the Next and repeat it, the Problem is, that it doesn‘t allow me to not get a result, or get 2 results…
Since i Would replace the just selected Index with my result, if the result is 0, then i can‘t work with it anymore and so can‘t get a new one in there. Now if i get 2, i also can‘t just place the Second result in an array higher or Lower than the current Index, because there are other Elements in those indexes, unless they resulted in a null before, But i can‘t rely on that, and i don‘t Even want that to happen…
Now, to avoid this, i could indeed just place each thing after the null index to index-1, to have that Index occupied, But that could result in a lot of operations (the array can reach basically as high as it can handle, so ~a million). And Same for adding an element, Would have to do Index+1 for each afterwards… The only place where this wouldn‘t matter is the last Index…
Now my question, is there something like this? I know it shouldn‘t work, But maybe there is a way i don‘t know, or Even a Special external Device that works like that?