This repository was archived by the owner on May 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSortedLinkedList.h
63 lines (50 loc) · 1.59 KB
/
SortedLinkedList.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
60
61
62
63
/* File: SortedLinkedList.h
* Course: CS216-00x
* Project: Project 2
* Purpose: The declaration of the Node class and the SortedLinkedList class
* Since these two classes have very closed relationship, we declare them in one header file
*
*** DO NOT CHANGE THIS FILE ***
*
*/
#ifndef SORTEDLINKEDLIST_H
#define SORTEDLINKEDLIST_H
#include <vector>
#include "card.h"
class Node
{
public:
Node();
Node(Card value);
friend class SortedLinkedList;
private:
Card data;
Node* next;
};
class SortedLinkedList
{
public:
//default constructor
SortedLinkedList();
// insert a new node which is a Card object to the list
// so that the nodes are in non-decreasing order of card values defined by poker game
void insert(Card newcard);
// remove the front node from the list
void pop_front();
// return how many nodes in the list
int size() const;
// return true if the list is empty
// otherwise return false
bool isEmpty() const;
// return a vector of cards
// which stores the data of each node from the sorted list.
// provide flexible way to access the data of each node in the list
vector<Card> access() const;
// display the nodes in the list from the front to the tail
void print() const;
//destructor
~SortedLinkedList();
private:
Node* head; //point at the first node in the list
};
#endif /* SORTEDLINKEDLIST_H */