changes taken over
This commit is contained in:
parent
17d5de15c9
commit
4eef7bfc01
@ -26,7 +26,7 @@ public:
|
|||||||
* @param maxSize
|
* @param maxSize
|
||||||
*/
|
*/
|
||||||
ArrayList(count_t maxSize) :
|
ArrayList(count_t maxSize) :
|
||||||
size(0), maxSize_(maxSize), allocated(true) {
|
size(0), maxSize_(maxSize), allocated(true) {
|
||||||
entries = new T[maxSize];
|
entries = new T[maxSize];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,14 +41,14 @@ public:
|
|||||||
* @param size size of data already present in storage
|
* @param size size of data already present in storage
|
||||||
*/
|
*/
|
||||||
ArrayList(T *storage, count_t maxSize, count_t size = 0) :
|
ArrayList(T *storage, count_t maxSize, count_t size = 0) :
|
||||||
size(size), entries(storage), maxSize_(maxSize), allocated(false) {
|
size(size), entries(storage), maxSize_(maxSize), allocated(false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copying is forbiden by declaring copy ctor and copy assignment deleted
|
* Copying is forbiden by declaring copy ctor and copy assignment deleted
|
||||||
* It is too ambigous in this case.
|
* It is too ambigous in this case.
|
||||||
* (Allocate a new backend? Use the same? What to do in an modifying call?)
|
* (Allocate a new backend? Use the same? What to do in an modifying call?)
|
||||||
*/
|
*/
|
||||||
ArrayList(const ArrayList& other) = delete;
|
ArrayList(const ArrayList& other) = delete;
|
||||||
const ArrayList& operator=(const ArrayList& other) = delete;
|
const ArrayList& operator=(const ArrayList& other) = delete;
|
||||||
|
|
||||||
@ -67,84 +67,84 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An Iterator to go trough an ArrayList
|
* An Iterator to go trough an ArrayList
|
||||||
*
|
*
|
||||||
* It stores a pointer to an element and increments the
|
* It stores a pointer to an element and increments the
|
||||||
* pointer when incremented itself.
|
* pointer when incremented itself.
|
||||||
*/
|
*/
|
||||||
class Iterator {
|
class Iterator {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Empty ctor, points to NULL
|
* Empty ctor, points to NULL
|
||||||
*/
|
*/
|
||||||
Iterator(): value(0) {}
|
Iterator(): value(0) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the Iterator to point to an element
|
* Initializes the Iterator to point to an element
|
||||||
*
|
*
|
||||||
* @param initialize
|
* @param initialize
|
||||||
*/
|
*/
|
||||||
Iterator(T *initialize) {
|
Iterator(T *initialize) {
|
||||||
value = initialize;
|
value = initialize;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current element the iterator points to
|
* The current element the iterator points to
|
||||||
*/
|
*/
|
||||||
T *value;
|
T *value;
|
||||||
|
|
||||||
Iterator& operator++() {
|
Iterator& operator++() {
|
||||||
value++;
|
value++;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator operator++(int) {
|
Iterator operator++(int) {
|
||||||
Iterator tmp(*this);
|
Iterator tmp(*this);
|
||||||
operator++();
|
operator++();
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator& operator--() {
|
Iterator& operator--() {
|
||||||
value--;
|
value--;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator operator--(int) {
|
Iterator operator--(int) {
|
||||||
Iterator tmp(*this);
|
Iterator tmp(*this);
|
||||||
operator--();
|
operator--();
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
T& operator*() {
|
T& operator*() {
|
||||||
return *value;
|
return *value;
|
||||||
}
|
}
|
||||||
|
|
||||||
const T& operator*() const {
|
const T& operator*() const {
|
||||||
return *value;
|
return *value;
|
||||||
}
|
}
|
||||||
|
|
||||||
T *operator->() {
|
T *operator->() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
const T *operator->() const {
|
const T *operator->() const {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//SHOULDDO this should be implemented as non-member
|
//SHOULDDO this should be implemented as non-member
|
||||||
bool operator==(const typename
|
bool operator==(const typename
|
||||||
ArrayList<T, count_t>::Iterator& other) const {
|
ArrayList<T, count_t>::Iterator& other) const {
|
||||||
return (value == other.value);
|
return (value == other.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
//SHOULDDO this should be implemented as non-member
|
//SHOULDDO this should be implemented as non-member
|
||||||
bool operator!=(const typename
|
bool operator!=(const typename
|
||||||
ArrayList<T, count_t>::Iterator& other) const {
|
ArrayList<T, count_t>::Iterator& other) const {
|
||||||
return !(*this == other);
|
return !(*this == other);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterator pointing to the first stored elmement
|
* Iterator pointing to the first stored elmement
|
||||||
|
Loading…
x
Reference in New Issue
Block a user