From 9e27c27ae8c8179340121e07578823a1ea9a662a Mon Sep 17 00:00:00 2001 From: JustinAJ Date: Tue, 3 Jun 2014 01:46:20 -0400 Subject: [PATCH] Added length-specifier constructor --- Jupiter/ArrayList.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Jupiter/ArrayList.h b/Jupiter/ArrayList.h index 6680b6e..8f0c9c9 100644 --- a/Jupiter/ArrayList.h +++ b/Jupiter/ArrayList.h @@ -81,6 +81,11 @@ namespace Jupiter */ ArrayList(); + /** + * @brief Initializes the ArrayList's underlying array to a specified size. + */ + ArrayList(size_t length); + /** * @brief Copy constructor for the ArrayList class. */ @@ -118,9 +123,13 @@ template unsigned int Jupiter::ArrayList::expandArray() return Jupiter::ArrayList::dataSize; } -template Jupiter::ArrayList::ArrayList() +template Jupiter::ArrayList::ArrayList() : ArrayList(length) +{ +} + +template Jupiter::ArrayList::ArrayList(size_t length) { - Jupiter::ArrayList::dataSize = INIT_SIZE; + Jupiter::ArrayList::dataSize = length; Jupiter::ArrayList::data = new T*[Jupiter::ArrayList::dataSize]; Jupiter::List::length = 0; }