-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlaylistArrayList.h
More file actions
109 lines (90 loc) · 3.09 KB
/
PlaylistArrayList.h
File metadata and controls
109 lines (90 loc) · 3.09 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/**@file PlaylistArrayList.h
* Interface for an Arraylist of playlists (from PlaylistList.h)
* @authors Forrest Wargo, Rup Patel, Elias Platt
*/
#ifndef COMP220_PLAYLISTARRAYLIST_H
#define COMP220_PLAYLISTARRAYLIST_H
#include <stdexcept>
#include <string>
#include "PlaylistList.h"
class PlaylistArrayList :public PlaylistList{
private:
//pointer to the start of the array
Playlist** array;
//count of the number of valid playlists currently stored in the array
int currPlaylistCount;
//size of the current array
int currCapacity;
/**
* replaces the old array with an array twice the size
* private method only called within PlaylistArrayList when necessary
* @post: array points to a new array of twice the size with values copied from the old one,
* the old array is deleted.
*/
void doubleCapacity();
public:
PlaylistArrayList();
/**
* Constructor
* @throws an std::invalid_argument exception if size < 1
*/
PlaylistArrayList(int initialCapacity);
//Copy Constructor
PlaylistArrayList(const PlaylistArrayList& arrayListToCopy);
//Overloaded Assignment Operator
PlaylistArrayList& operator=(PlaylistArrayList *arrayListToCopy);
//Destructor
~PlaylistArrayList();
/**
* appends the new playlist to the end of the list
* @post the list has an additional value in it, at the end
*/
void insertAtEnd(Playlist* playlistToAdd);
/**
* gets a playlist from the list
* @param index the location from which to get the value
* @return a copy of the playlist at index
* @throws out_of_range exception if index is invalid
*/
Playlist* getValueAt(int index);
/**
* gives a string representation of the current list
* @returns a string representing the given list in the exact format shown below
* {1, 2, 3, 4, 5}
*/
std::string toString();
/**
* checks if there are any valid playlists in the list
* @return true if there are no valid playlists in the list, false otherwise
*/
bool isEmpty();
/**
* returns a count of valid playlists currently in the list
* @returns the number of valid playlists in the list
*/
int playlistCount();
/**
* makes the list empty of valid playlists
* @post the list is empty, such that isEmpty() == true
*/
void clearList();
/**
* Searches an int array for a certain value
* @return the index of the first occurrence of numToFind if it is present, otherwise returns -1
*/
int find(std::string playlistToFind);
/**
* removes the playlist at index from the list, and returns a copy of that playlist
* @param index the location from which to get the value
* @post the playlist at index is removed from the list, everything else is shifted down one
* @return a copy of the playlist at index
* @throws out_of_range exception if index is invalid
*/
void removeAt(int index);
/**
*
* @return pointer to the array
*/
Playlist** getArray();
};
#endif //COMP220_PLAYLISTARRAYLIST_H