-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArrayBag.h
33 lines (30 loc) · 964 Bytes
/
ArrayBag.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
#ifndef _ARRAY_BAG
#define _ARRAY_BAG
#include "BagInterface.h"
template<class ItemType>
class ArrayBag : public BagInterface<ItemType>
{
private:
static const int DEFAULT_CAPACITY = 4;
ItemType* itemArray; //array must be dynamic; so pointers are very yes
int numberOfItems;
int myCapacity; //added variable to track capacity
public:
ArrayBag(int capacity = DEFAULT_CAPACITY); // new constructor
ArrayBag(const ArrayBag& anotherBag); // copy constructor
~ArrayBag(); //destructor
int getCurrentSize() const;
int getCapacity() const;
void resize(int newCapacity); // resize
bool isEmpty() const;
bool isFull() const;
bool add(const ItemType& newEntry);
bool remove(const ItemType& anEntry);
void clear();
bool contains(const ItemType& anEntry) const;
int getFrequencyOf(const ItemType& anEntry) const;
vector<ItemType> toVector() const;
ArrayBag& operator=(const ArrayBag& anotherBag);
};
#include "ArrayBag.cxx"
#endif