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
|
/// LinkedList.hh apdated for use in bbtools 23-10-1998 by John Kennis
//
//
// Original notice:
//
//
// LinkedList.hh for Blackbox - an X11 Window manager
// Copyright (c) 1997, 1998 by Brad Hughes, bhughes@tcac.net
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// (See the included file COPYING / GPL-2.0)
//
#ifndef __LinkedList_hh
#define __LinkedList_hh
typedef struct __llist_node {
__llist_node *prev, *next;
void *data;
} __llist_node;
// forward declaration
class __llist;
class __llist_iterator {
private:
__llist *list;
__llist_node *node;
protected:
__llist_iterator(__llist *);
~__llist_iterator(void);
void *current(void);
void reset(void);
void resetLast(void);
const int set(const int);
void operator++(int);
void operator--(int);
};
class __llist {
private:
int elements;
__llist_node *_first, *_last;
friend class __llist_iterator;
protected:
__llist(void * = 0);
~__llist(void);
const int count(void) const { return elements; }
const int empty(void) const { return (elements == 0); }
void *find(const int);
const int insert(void *, int = -1);
const int remove(void *);
void *remove(const int);
void *first(void) { return _first->data; }
void *last(void) { return _last->data; }
};
template <class Z>
class LinkedListIterator : public __llist_iterator {
public:
LinkedListIterator(__llist *d = 0) : __llist_iterator(d) { }
~LinkedListIterator(void) { }
Z *current(void) { return (Z *) __llist_iterator::current(); }
void reset(void) { __llist_iterator::reset(); }
void resetLast(void) { __llist_iterator::resetLast(); }
const int set(const int i) { return __llist_iterator::set(i); }
void operator++(int a) { __llist_iterator::operator++(a); }
void operator--(int a) { __llist_iterator::operator--(a); }
};
template <class Z>
class LinkedList : public __llist {
public:
LinkedList(Z *d = 0) : __llist(d) { }
~LinkedList(void) { }
const int count(void) const { return __llist::count(); }
const int empty(void) const { return __llist::empty(); }
Z *find(const int i) { return (Z *) __llist::find(i); }
const int insert(Z *d, int i = -1) { return __llist::insert((void *) d, i); }
const int remove(Z *d) { return __llist::remove((void *) d); }
Z *remove(const int i) { return (Z *) __llist::remove(i); }
Z *first(void) { return (Z *) __llist::first(); }
Z *last(void) { return (Z *) __llist::last(); }
};
#endif // __LinkedList_hh
|