-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathLinkedList.h
More file actions
49 lines (38 loc) · 882 Bytes
/
Copy pathLinkedList.h
File metadata and controls
49 lines (38 loc) · 882 Bytes
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
#pragma once
#include <iostream>
using namespace std;
class LinkedList
{
public:
// This node contains data and the XOR between the previous and next nodes
struct Node
{
int data;
Node *both;
Node(int data);
};
// Mutators:
void add(int data);
// Accessors:
Node *get(int index);
int getCount();
// Constructor:
LinkedList();
// Copy Constructor
LinkedList(const LinkedList &rhs);
// Operator overloads:
const int &operator[](unsigned int index) const;
int & operator[](unsigned int index);
LinkedList &operator=(const LinkedList &rhs);
// Print list:
void printList();
void printListReverse();
// Destructor
~LinkedList();
private:
Node *head;
Node *tail;
int count;
void Set(const LinkedList &other);
Node *xorCalc(Node *a, Node *b);
};