Improve Vector module and reserve documentation

This commit is contained in:
Eugen Wissner 2017-02-20 12:03:49 +01:00
parent 70632d975d
commit 3c23aca6a6

View File

@ -3,6 +3,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/** /**
* One-dimensional array.
*
* Copyright: Eugene Wissner 2016-2017. * Copyright: Eugene Wissner 2016-2017.
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/, * License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
* Mozilla Public License, v. 2.0). * Mozilla Public License, v. 2.0).
@ -372,6 +374,13 @@ struct Vector(T)
return capacity_; return capacity_;
} }
///
@safe @nogc unittest
{
auto v = Vector!int(4);
assert(v.capacity == 4);
}
/** /**
* Returns: Vector length. * Returns: Vector length.
*/ */
@ -442,6 +451,10 @@ struct Vector(T)
/** /**
* Reserves space for $(D_PARAM size) elements. * Reserves space for $(D_PARAM size) elements.
* *
* If $(D_PARAM size) is less than or equal to the $(D_PSYMBOL capacity), the
* function call does not cause a reallocation and the vector capacity is not
* affected.
*
* Params: * Params:
* size = Desired size. * size = Desired size.
*/ */
@ -483,7 +496,7 @@ struct Vector(T)
} }
/// ///
unittest @nogc @safe unittest
{ {
Vector!int v; Vector!int v;
assert(v.capacity == 0); assert(v.capacity == 0);
@ -518,7 +531,7 @@ struct Vector(T)
} }
/// ///
unittest @nogc @safe unittest
{ {
Vector!int v; Vector!int v;
assert(v.capacity == 0); assert(v.capacity == 0);