async: Switch to the internal use of the vector instead of built-in arrays

This commit is contained in:
2017-01-12 10:17:12 +01:00
parent 4de42ca227
commit cb6cc65113
4 changed files with 54 additions and 41 deletions

View File

@ -1083,7 +1083,7 @@ struct Vector(T)
* Params:
* dg = $(D_KEYWORD foreach) body.
*/
int opApply(scope int delegate(ref T) dg)
int opApply(scope int delegate(ref T) @nogc dg)
{
T* end = vector + length_ - 1;
for (T* begin = vector; begin != end; ++begin)
@ -1098,7 +1098,7 @@ struct Vector(T)
}
/// Ditto.
int opApply(scope int delegate(ref size_t i, ref T) dg)
int opApply(scope int delegate(ref size_t i, ref T) @nogc dg)
{
for (size_t i = 0; i < length_; ++i)
{
@ -1395,6 +1395,19 @@ struct Vector(T)
assert(v2[1] == 3);
}
/**
* Returns an array used internally by the vector to store its owned elements.
* The length of the returned array may differ from the size of the allocated
* memory for the vector: the array contains only initialized elements, but
* not the reserved memory.
*
* Returns: The array with elements of this vector.
*/
inout(T[]) data() inout
{
return vector[0 .. length];
}
mixin DefaultAllocator;
}