-
Notifications
You must be signed in to change notification settings - Fork 1
/
isllist.h
124 lines (100 loc) · 2.82 KB
/
isllist.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
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
* Abuse - dark 2D side-scrolling platform game
* Copyright (c) 1995 Crack dot Com
* Copyright (c) 2005-2011 Sam Hocevar <[email protected]>
*
* This software was released into the Public Domain. As with most public
* domain software, no warranty is made or implied by Crack dot Com, by
* Jonathan Clark, or by Sam Hocevar.
*/
#ifndef ISLLIST_HH
#define ISLLIST_HH
// "inc/isllist.h", line 13.10: 1540-016: (S) protected member "isllist<tcpip_protocol::RequestItem*>::list_node *" cannot be accessed.
template <class T>
class isllist
{
public:
class list_node
{
public:
list_node * next;
T data;
list_node() { }
list_node(const T& item) { data = item; }
};
list_node * list;
class iterator
{
public:
// pseudo-protected - don't use unless you really have to
list_node * node;
iterator(list_node * p) : node(p) { }
iterator() { }
iterator(const iterator &p) : node(p.node) { }
int operator==(const iterator &p) { return (node == p.node); }
int operator!=(const iterator &p) { return (node != p.node); }
iterator& operator++() { node = node->next; return *this; }
iterator next() { return node->next; }
T& operator*() { return node->data; }
};
iterator end() { return (list_node *)(&list); }
iterator begin_prev() { return end(); }
iterator begin() { return list; }
int empty() { return begin() == end(); }
iterator insert_next(iterator pos, T& item)
{
list_node * p = new list_node(item);
p->next = pos.node->next;
pos.node->next = p;
return p;
}
void erase_next(iterator pos)
{
list_node * p = pos.node->next;
pos.node->next = p->next;
delete p;
}
int find_prev(iterator& p, T& item)
{
while (p.node->next != end().node)
{
if (*(p.next())==item)
return 1;
++p;
}
return 0;
}
void move_next(const iterator&p, const iterator&q)
{
list_node * tmp;
tmp = p.node->next;
if (tmp == q.node)
return;
p.node->next = tmp->next;
tmp->next = q.node->next;
q.node->next = tmp;
}
int find(T& item) { iterator p = begin_prev(); return find_prev(p, item); }
void insert(T& item) { insert_next( begin_prev(), item); }
void erase() { erase_next( begin_prev() ); }
void erase_all()
{
while (!empty())
erase();
}
isllist()
{
list = (list_node *)&list;
}
~isllist()
{
erase_all();
}
};
#endif
/*
"inc/isllist.h", line 9.8: 1540-051: (S) A declaration has been made without a type specification.
"inc/isllist.h", line 9.8: 1540-022: (S) "isllist" was previously declared as "type name".
"inc/isllist.h", line 9.1: 1540-377: (I) "isllist" is declared on line 6 of "/u/crack/abuse/inc/isllist.h".
"inc/isllist.h", line 16.10: 1540-016: (S) protected member "isllist<tcpip_protocol::RequestItem*>::list_node *" cannot be accessed.
*/