Random-access range
Warning: break range
Warning: break range
1 import std.algorithm : equal; 2 auto q = Deque!int(); 3 4 assert(equal(q[], new int[0])); 5 q.insertBack(1); 6 assert(equal(q[], [1])); 7 q.insertBack(2); 8 assert(equal(q[], [1, 2])); 9 q.insertFront(3); 10 assert(equal(q[], [3, 1, 2])); 11 q.removeFront; 12 assert(equal(q[], [1, 2])); 13 q.insertBack(4); 14 assert(equal(q[], [1, 2, 4])); 15 q.insertFront(5); 16 assert(equal(q[], [5, 1, 2, 4])); 17 q.removeBack(); 18 assert(equal(q[], [5, 1, 2]));
Deque on ring buffer