Queue/Usage: Difference between revisions

Improved D entry
m (→‎{{header|Lua}}: Add missing end tag)
(Improved D entry)
Line 574:
private size_t first, last;
private T[] A = [T.init];
 
this(T[] items...) pure nothrow @safe {
foreach (x; items)
push(x);
}
 
@property bool empty() const pure nothrow @safe @nogc {
return length == 0;
}
 
@property T front() pure nothrow @safe @nogc {
assert(length != 0);
return A[first];
}
 
T opIndex(in size_t i) pure nothrow @safe @nogc {
assert(i < length);
return A[(first + i) & (A.length - 1)];
}
 
Line 596 ⟶ 611:
 
@property T pop() pure nothrow @safe @nogc {
assert(length != 0);
auto saved = A[first];
static if (hasIndirections!T)