From 41b40af36198fb013a2034a1954bbc4df50fea8b Mon Sep 17 00:00:00 2001 From: "FWoltermann@gmail.com" Date: Mon, 28 May 2012 14:50:07 +0000 Subject: Changes ArrayList to be an alias of std::vector, and Floatlist to be an alias of std::vector in preparation of removing these things completely --- FoundationEx/ArrayList.h | 61 ++++++++++++++++++++---------------------------- 1 file changed, 25 insertions(+), 36 deletions(-) (limited to 'FoundationEx/ArrayList.h') diff --git a/FoundationEx/ArrayList.h b/FoundationEx/ArrayList.h index 6917d9b..c0985c3 100644 --- a/FoundationEx/ArrayList.h +++ b/FoundationEx/ArrayList.h @@ -10,6 +10,9 @@ OVERVIEW ======== Simple untyped array list + + The E: That is going to be removed very very soon. For now, it has been aliased to std::vector + (or std::vector for FloatList). Full conversion to std::vector is still needed. */ #ifndef ArrayList_h @@ -20,14 +23,16 @@ #include #endif +#include + // +-------------------------------------------------------------------+ class ArrayList { public: - ArrayList() : items(0), extent(0), array(0) { } + ArrayList() { array.clear(); } ArrayList(const ArrayList& l); - ~ArrayList() { delete [] array; } + ~ArrayList() { } DWORD operator[](int i) const; DWORD& operator[](int i); @@ -39,15 +44,15 @@ public: void insert(const DWORD val, int index=0); void insertSort(DWORD val); - DWORD first() const { return operator[](0); } - DWORD last() const { return operator[](items-1); } + DWORD first() const { return *array.begin(); } + DWORD last() const { return array.back(); } void remove(DWORD val); void removeIndex(int index); void clear(); - int size() const { return items; } - bool isEmpty() const { return !items; } + int size() const { return array.size(); } + bool isEmpty() const { return array.size() == 0; } bool contains(DWORD val) const; int count(DWORD val) const; @@ -56,15 +61,14 @@ public: void sort(); void shuffle(); + bool check(int& index) const; + private: - void qsort(DWORD* a, int lo, int hi); - void swap(DWORD* a, int i, int j); + void swap(int i, int j); void resize(int newsize); - bool check(int& index) const; + - int items; - int extent; - DWORD* array; + std::vector array; friend class ArrayListIter; }; @@ -102,49 +106,34 @@ private: // +-------------------------------------------------------------------+ // +-------------------------------------------------------------------+ -class FloatList +class FloatList : public ArrayList { public: - FloatList() : items(0), extent(0), array(0) { } + FloatList() { array.clear(); } FloatList(const FloatList& l); - ~FloatList() { delete [] array; } + ~FloatList() {} float operator[](int i) const; float& operator[](int i); float at(int i) const; float& at(int i); - void append(const FloatList& list); void append(const float val); + void append(const FloatList& list); void insert(const float val, int index=0); void insertSort(float val); - float first() const { return operator[](0); } - float last() const { return operator[](items-1); } + float first() const { return *array.begin(); } + float last() const { return array.back(); } void remove(float val); - void removeIndex(int index); - - void clear(); - int size() const { return items; } - bool isEmpty() const { return !items; } - - bool contains(float val) const; + bool contains(float val) const; int count(float val) const; int index(float val) const; - - void sort(); - void shuffle(); - + private: - void qsort(float* a, int lo, int hi); - void swap(float* a, int i, int j); - void resize(int newsize); - bool check(int& index) const; - int items; - int extent; - float* array; + std::vector array; friend class FloatListIter; }; -- cgit v1.1