-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArrayList.h
42 lines (34 loc) · 1.35 KB
/
ArrayList.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <iostream>
#ifndef ARRAYLIST_H
#define ARRAYLIST_H
class ArrayList
{
private:
int capacity; // capacity of the array
int used; // number of array elements currently in use
int* pArray; // pointer to a dynamically allocated array of integers
void resize();
public:
// constructors
ArrayList(); // default constructor
ArrayList(const ArrayList &arrayToCopy); // copy constructor
ArrayList(ArrayList&& arrayToMove); // move constructor
// assignment operators
ArrayList& operator=(const ArrayList &rhs); // copy assignment operator
ArrayList& operator=(ArrayList &&rhs); // move assignment operator
~ArrayList(); // destructor
// getters
int getCapacity() const;
int *getPArray() const;
int size() const;
// member functions
bool empty() const;
bool full() const;
bool contains(int x) const;
bool get(int position, int& value) const;
void pushBack(int x);
void print(std::ostream &output) const;
// << operator overload
friend std::ostream &operator<<(std::ostream &output, const ArrayList &listToPrint);
};
#endif