summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2017-02-20 12:03:49 +0100
committerEugen Wissner <belka@caraus.de>2017-02-20 12:03:49 +0100
commit3c23aca6a67f87e37bd858a824aa14d192f2977f (patch)
tree9a6e3c42b22a2390d35e5017f0b11e95be1e51d8
parent70632d975da09471d0fac5df51a96bd3d9bbeb6f (diff)
downloadtanya-3c23aca6a67f87e37bd858a824aa14d192f2977f.tar.gz
Improve Vector module and reserve documentation
-rw-r--r--source/tanya/container/vector.d17
1 files changed, 15 insertions, 2 deletions
diff --git a/source/tanya/container/vector.d b/source/tanya/container/vector.d
index b38c0a4..954ca20 100644
--- a/source/tanya/container/vector.d
+++ b/source/tanya/container/vector.d
@@ -3,6 +3,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
+ * One-dimensional array.
+ *
* Copyright: Eugene Wissner 2016-2017.
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
* Mozilla Public License, v. 2.0).
@@ -372,6 +374,13 @@ struct Vector(T)
return capacity_;
}
+ ///
+ @safe @nogc unittest
+ {
+ auto v = Vector!int(4);
+ assert(v.capacity == 4);
+ }
+
/**
* Returns: Vector length.
*/
@@ -442,6 +451,10 @@ struct Vector(T)
/**
* 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:
* size = Desired size.
*/
@@ -483,7 +496,7 @@ struct Vector(T)
}
///
- unittest
+ @nogc @safe unittest
{
Vector!int v;
assert(v.capacity == 0);
@@ -518,7 +531,7 @@ struct Vector(T)
}
///
- unittest
+ @nogc @safe unittest
{
Vector!int v;
assert(v.capacity == 0);