Java equivalent of std::deque

前端 未结 4 1807
执念已碎
执念已碎 2020-12-10 13:36

I\'m a relatively new Java programmer coming from C++/STL, and am looking for a class with these characteristics (which the C++ std::deque has, as I understand it):

4条回答
  •  一生所求
    2020-12-10 14:26

    Primitive Collections for Java has an ArrayDeque with a get(int idx) method.

    http://sourceforge.net/projects/pcj

    I can't vouch for the quality of this project though.

    An alternative would be to get the JDK ArrayDeque source and add the get(int idx) method yourself. Should be relatively easy.

    EDIT: If you intend to use the deque in a highly multi-threaded manner, I would go the "patch the JDK's ArrayDeque" route. This implementation has been tested thoroughly and is used in the new java.util.concurrent ForkJoin framework.

提交回复
热议问题