32 typedef int (*
Comparer)(
const Element& lhs,
const Element& rhs);
35 Vector(
unsigned int initialCapacity = 10,
unsigned int capacityIncrement = 10);
41 bool contains(
const Element& elem)
const;
43 int indexOf(
const Element& elem)
const;
47 unsigned int count()
const override 51 unsigned int size()
const;
53 bool add(
const Element& obj)
66 bool setSize(
unsigned int newSize);
68 const Element&
elementAt(
unsigned int index)
const;
70 const void remove(
unsigned int index);
72 bool setElementAt(
const Element& obj,
unsigned int index);
73 const Element&
get(
unsigned int index)
const 78 const Element&
operator[](
unsigned int index)
const override;
79 Element&
operator[](
unsigned int index)
override;
89 if(
_data !=
nullptr) {
97 other._data =
nullptr;
100 other._increment = 0;
122 if(
_data ==
nullptr) {
134 if(
_data !=
nullptr) {
142 if(
_data ==
nullptr) {
146 for(
unsigned int i = 0; i <
_size; i++) {
169 if(array !=
nullptr) {
170 for(
unsigned int i = 0; i <
_size; i++) {
171 array[i] = *
_data[i];
182 return *
_data[index];
196 for(
unsigned int i = 0; i <
_size; i++) {
197 if(*
_data[i] == elem) {
226 unsigned int i =
_size;
230 if(*
_data[i] == elem) {
268 Element** temp =
new Element*[newCapacity];
270 if(temp ==
nullptr) {
275 memcpy(temp,
_data,
sizeof(Element*) *
_size);
295 Element* newItem =
new Element(obj);
296 if(newItem ==
nullptr) {
300 for(
unsigned int i = index; i <=
_size; i++) {
301 Element* tmp =
_data[i];
322 for(
unsigned int i = 0; i <
_size; i++) {
331 for(
unsigned int i = 0; i <
_size; i++) {
332 if(*
_data[i] == obj) {
350 for(i = index + 1; i <
_size; i++) {
373 if(newSize <
_size) {
374 for(
unsigned int i = newSize; i <
_size; i++) {
387 Element** temp =
new Element*[
_size];
388 if(temp ==
nullptr) {
392 for(
unsigned int i = 0; i <
_size; i++) {
417 return *
_data[index];
422 for(
unsigned j = 1; j <
_size; j++)
424 Element* key =
_data[j];
426 for(i = j - 1; (i >= 0) && compareFunction(*
_data[i], *key) > 0; i--)
const Element & lastElement() const
Definition: WVector.h:210
int lastIndexOf(const Element &elem) const
Definition: WVector.h:219
void trimToSize()
Definition: WVector.h:384
bool contains(const Element &elem) const
Definition: WVector.h:162
unsigned int _increment
Definition: WVector.h:112
int indexOf(const Element &elem) const
Definition: WVector.h:194
const Element & elementAt(unsigned int index) const
Definition: WVector.h:176
Definition: Countable.h:20
Vector class template.
Definition: WVector.h:29
const Vector< Element > & operator=(const Vector< Element > &rhv)
Definition: WVector.h:81
Element ** _data
Definition: WVector.h:113
unsigned int capacity() const
Definition: WVector.h:157
const void remove(unsigned int index)
Definition: WVector.h:314
bool ensureCapacity(unsigned int minCapacity)
Definition: WVector.h:261
unsigned int _capacity
Definition: WVector.h:111
bool insertElementAt(const Element &obj, unsigned int index)
Definition: WVector.h:281
bool add(const Element &obj)
Definition: WVector.h:53
bool isEmpty() const
Definition: WVector.h:205
void removeElementAt(unsigned int index)
Definition: WVector.h:340
unsigned int count() const override
Definition: WVector.h:47
bool setSize(unsigned int newSize)
Definition: WVector.h:367
void sort(Comparer compareFunction)
Definition: WVector.h:420
int(* Comparer)(const Element &lhs, const Element &rhs)
Definition: WVector.h:32
bool removeElement(const Element &obj)
Definition: WVector.h:329
const Vector< Element > & operator=(const Vector< Element > &&other)
Definition: WVector.h:87
void copyFrom(const Vector &rhv)
Definition: WVector.h:132
~Vector()
Definition: WVector.h:151
void removeAllElements()
Definition: WVector.h:319
unsigned int _size
Definition: WVector.h:110
bool setElementAt(const Element &obj, unsigned int index)
Definition: WVector.h:357
void clear()
Definition: WVector.h:59
const Element & operator[](unsigned int index) const override
Definition: WVector.h:403
const Element & firstElement() const
Definition: WVector.h:185
Vector(unsigned int initialCapacity=10, unsigned int capacityIncrement=10)
Definition: WVector.h:116
unsigned int size() const
Definition: WVector.h:238
bool addElement(const Element &obj)
Definition: WVector.h:243
void copyInto(Element *array) const
Definition: WVector.h:167