-
Notifications
You must be signed in to change notification settings - Fork 0
/
AdjustableArray.h
59 lines (45 loc) · 1.1 KB
/
AdjustableArray.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// AdjustableArray
#ifndef ADJUSTABLE_ARRAY_H
#define ADJUSTABLE_ARRAY_H
#include <iostream>
#include "Array.h"
struct node
{
int data;
struct node *next;
};
class AdjustableArray : public Array
{
public:
// Default constructor
AdjustableArray();
// Nondefault constructor
AdjustableArray(int aLen);
// Copy contstructor
// AdjustableArray(const AdjustableArray & other);
// Destructor
// ~AdjustableArray();
// Assign operator
// AdjustableArray & operator=(const AdjustableArray & other);
void output(std::ostream & s = std::cout) const;
const int & operator[](int which) const;
int & operator[](int which);
int find(int aData) const;
void insertAfter(int aExistingEntry, int aData);
void deleteThis(int aData);
protected:
void setLength(int aLen);
private:
node *head,*tail;
int * mA;
int mLen;
int mCap;
void copy(const AdjustableArray & other);
void allocate(int aLen);
bool atCapacity();
int findLastIdx();
node * findPreviousNode(int aData);
node * addNode(int n);
};
std::ostream & operator<<(std::ostream & s, const AdjustableArray & a);
#endif