-
Notifications
You must be signed in to change notification settings - Fork 0
/
llp.h
77 lines (59 loc) · 1.59 KB
/
llp.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*llp.h
*#include "no_such_object_exception.h"
*/
#ifndef LINKED_LIST_H
#define LINKED_LIST_H
#include <iostream>
#include "Document.h"
struct Double_node
{
Document *doc;
/*
* pointers to the previous and next nodes,
* this is the distinguishing feature of the doubly
* linked list
*/
Double_node *prev;
Double_node *next;
};
class Double_list
{
public:
/* constructor for empty object */
Double_list ();
/*
* copy constructor needed to be able to make deep copies
* of objects. Should the assignment operator have been overloaded
* I cannot figure out how to call this constructor explicitly.
*/
Double_list (const Double_list& a_list);
/* destructor - basically a tail ended pop */
~Double_list ();
/* checks if the node is empty */
bool is_empty () const;
/* returns the length */
int get_length () const;
/* adds the doc to the end of the list.*/
void doc_add (Document *new_doc);
/* finds then remove the node */
bool remove (std::string name);
/* remove without providing pointer*/
void kill ();
/* pop function - tail end pop */
Document* pop ();
Document* dequeue ();
void print ();
void print (std::ostream &os);
Document* retrieve (std::string name) const;
// throw (No_such_object_exception);
protected:
/*
* the total size of the list
* and and a pointer to the node
*/
int size;
Double_node *head;
Double_node *tail;
Double_node *find (std::string name) const;
};
#endif