1 // LinkedList.h for Openbox
2 // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
4 // Permission is hereby granted, free of charge, to any person obtaining a
5 // copy of this software and associated documentation files (the "Software"),
6 // to deal in the Software without restriction, including without limitation
7 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 // and/or sell copies of the Software, and to permit persons to whom the
9 // Software is furnished to do so, subject to the following conditions:
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 // DEALINGS IN THE SOFTWARE.
22 #ifndef __LinkedList_hh
23 #define __LinkedList_hh
34 __llist_node(void) { next = (__llist_node *) 0; data = (void *) 0; }
36 inline __llist_node *getNext(void) { return next; }
38 inline void *getData(void) { return data; }
39 inline void setData(void *d) { data = d; }
40 inline void setNext(__llist_node *n) { next = n; }
44 // forward declaration
48 class __llist_iterator {
57 __llist_iterator(__llist *);
58 ~__llist_iterator(void);
60 const int set(const int);
65 void operator++(void);
73 __llist_node *_first, *_last;
76 friend class __llist_iterator;
83 inline const int &count(void) const { return elements; }
84 inline const int empty(void) const { return (elements == 0); }
86 const int insert(void *, int = -1);
87 const int remove(void *);
89 void *find(const int);
90 void *remove(const int);
97 class LinkedListIterator : public __llist_iterator {
99 LinkedListIterator(__llist *d = 0) : __llist_iterator(d) { return; }
101 inline Z *current(void) { return (Z *) __llist_iterator::current(); }
103 inline const int set(const int i) { return __llist_iterator::set(i); }
105 inline void reset(void) { __llist_iterator::reset(); }
107 inline void operator++(void) { __llist_iterator::operator++(); }
108 inline void operator++(int) { __llist_iterator::operator++(0); }
113 class LinkedList : public __llist {
115 LinkedList(Z *d = 0) : __llist(d) { return; }
117 inline Z *find(const int i) { return (Z *) __llist::find(i); }
118 inline Z *remove(const int i) { return (Z *) __llist::remove(i); }
119 inline Z *first(void) { return (Z *) __llist::first(); }
120 inline Z *last(void) { return (Z *) __llist::last(); }
122 inline const int count(void) const { return __llist::count(); }
123 inline const int empty(void) const { return __llist::empty(); }
125 inline const int insert(Z *d, int i = -1) { return __llist::insert((void *) d, i); }
126 inline const int remove(Z *d) { return __llist::remove((void *) d); }
130 #endif // __LinkedList_hh