summaryrefslogtreecommitdiffstats
path: root/src/libs/engine/Array.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-02-09 22:39:56 +0000
committerDavid Robillard <d@drobilla.net>2007-02-09 22:39:56 +0000
commite343345cf54172720f3494ccef87d62b2c688d0a (patch)
tree67c6b3f95e9393110f78b6fa0cf44cbd12f935a4 /src/libs/engine/Array.h
parentc50fe49fea7e32b3194b163b77ee5a52480ffa33 (diff)
downloadingen-e343345cf54172720f3494ccef87d62b2c688d0a.tar.gz
ingen-e343345cf54172720f3494ccef87d62b2c688d0a.tar.bz2
ingen-e343345cf54172720f3494ccef87d62b2c688d0a.zip
Moved Deletable (formerly MaidObject), List, and Array from Ingen to Raul.
git-svn-id: http://svn.drobilla.net/lad/ingen@294 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/engine/Array.h')
-rw-r--r--src/libs/engine/Array.h106
1 files changed, 0 insertions, 106 deletions
diff --git a/src/libs/engine/Array.h b/src/libs/engine/Array.h
deleted file mode 100644
index 6c63d44c..00000000
--- a/src/libs/engine/Array.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) any later
- * version.
- *
- * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef ARRAY_H
-#define ARRAY_H
-
-#include "MaidObject.h"
-#include <cassert>
-#include <cstdlib>
-#include "types.h"
-
-
-/** An array.
- *
- * Has a stack-like push_back() too, for find_process_order...
- */
-template <class T>
-class Array : public MaidObject
-{
-public:
- Array(size_t size = 0) : _size(size), _top(0), _elems(NULL) {
- if (size > 0)
- _elems = new T[size];
- }
-
- Array(size_t size, T initial_value) : _size(size), _top(0), _elems(NULL) {
- if (size > 0) {
- _elems = new T[size];
- for (size_t i=0; i < size; ++i)
- _elems[i] = initial_value;
- }
- }
-
- Array(size_t size, const Array<T>& contents) : _size(size), _top(size+1) {
- _elems = new T[size];
- if (size <= contents.size())
- memcpy(_elems, contents._elems, size * sizeof(T));
- else
- memcpy(_elems, contents._elems, contents.size() * sizeof(T));
- }
-
- ~Array() {
- free();
- }
-
- void alloc(size_t num_elems) {
- assert(num_elems > 0);
-
- delete[] _elems;
- _size = num_elems;
- _top = 0;
-
- _elems = new T[num_elems];
- }
-
- void alloc(size_t num_elems, T initial_value) {
- assert(num_elems > 0);
-
- delete[] _elems;
- _size = num_elems;
- _top = 0;
-
- _elems = new T[num_elems];
- for (size_t i=0; i < _size; ++i)
- _elems[i] = initial_value;
- }
-
- void free() {
- delete[] _elems;
- _size = 0;
- _top = 0;
- }
-
- void push_back(T n) {
- assert(_top < _size);
- _elems[_top++] = n;
- }
-
- inline size_t size() const { return _size; }
-
- inline T& operator[](size_t i) const { assert(i < _size); return _elems[i]; }
-
- inline T& at(size_t i) const { assert(i < _size); return _elems[i]; }
-
-private:
- size_t _size;
- size_t _top; // points to empty element above "top" element
- T* _elems;
-};
-
-
-#endif // ARRAY_H