ArrayDeque derives from ArrayAbstractQueue. Instead can derive from ArrayQueue to reuse the functions.data[i] = arrayAbstractQueue.data[(arrayAbstractQueue.headIndex + i) % arrayAbstractQueue.getArraySize()];But in the MIL, also copied
headIndex. Either reset headIndex to 0, or use data[(headIndex + i) % getArraySize()] while copying the elements. Otherwise the copied container has a corrupted circular array.
headIndex - 1 + getArraySize()" might cause an underflow. + and - are left-to-right associativity, so we will do "headIndex - 1" first, which might go negative, and unsigned int will cause it to underflow into the largest possible unsigned int value. Then, subsequent "+ getArraySize()" might overflow back to the correct number. Still, safer to use use "headIndex + getArraySize() - 1" instead to avoid underflow/overflow.