PeterHiggs
PeterHiggs

Reputation: 97

Swap Objects in an ArrayDeque (Java)

If I have an ArrayList, I can swap two objects using Collections.swap(list, indexA, indexB).

Is there anything similar for an ArrayDeque?

Upvotes: 0

Views: 392

Answers (1)

Pierre Rust
Pierre Rust

Reputation: 2504

No ArrayDequeue is a Dequeue implementation, which means it is meant to be used to insert and remove elements only at start and end of the collection. It does not provide indexed access to elements (unlike List).

If you need indexed access to elements, and swap operation, you should reconsider your design and use another Collection type.

Upvotes: 3

Related Questions