It looks like you need a deck like python deque , except that you may prefer indexed access performance characteristics for C ++ std::deque<T> , the documentation is somewhat dumb.
Java comes with java.util.Deque implementations that you could use, just like the @tnoda java.util.LinkedList clause.
If you rode on your own, the implementation is quite simple for a fickle collection and seems to me intuitive enough, at least for the implementation against the "hashed arrays" underlying clojure hashmap and vector, or directly against the vector initially, if the details annoy you.
source share