aboutsummaryrefslogtreecommitdiff
path: root/common/array.h
diff options
context:
space:
mode:
Diffstat (limited to 'common/array.h')
-rw-r--r--common/array.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/common/array.h b/common/array.h
index 693c024d11..2db0ed2a8b 100644
--- a/common/array.h
+++ b/common/array.h
@@ -46,12 +46,20 @@ public:
public:
Array() : _capacity(0), _size(0), _storage(0) {}
Array(const Array<T> &array) : _capacity(0), _size(0), _storage(0) {
- _size = array._size;
- _capacity = _size + 32;
+ _capacity = _size = array._size;
_storage = new T[_capacity];
copy(array._storage, array._storage + _size, _storage);
}
+ /**
+ * Construct an array by copying data from a regular array.
+ */
+ Array(const T *data, int n) {
+ _capacity = _size = n;
+ _storage = new T[_capacity];
+ copy(data, data + _size, _storage);
+ }
+
~Array() {
delete[] _storage;
}