Coda Distributed File System
coda-src
util
dlist.h
Go to the documentation of this file.
1
/* BLURB gpl
2
3
Coda File System
4
Release 8
5
6
Copyright (c) 1987-2025 Carnegie Mellon University
7
Additional copyrights listed below
8
9
This code is distributed "AS IS" without warranty of any kind under
10
the terms of the GNU General Public Licence Version 2, as shown in the
11
file LICENSE. The technical and financial contributors to Coda are
12
listed in the file CREDITS.
13
14
Additional copyrights
15
none currently
16
17
#*/
18
19
/*
20
*
21
* dlist.h -- Specification of doubly-linked list type where list elements
22
* can be on only one list at a time and are kept in sorted order.
23
*
24
*/
25
26
#ifndef _UTIL_DLIST_H_
27
#define _UTIL_DLIST_H_ 1
28
29
#ifdef __cplusplus
30
extern
"C"
{
31
#endif
32
33
#include <stdio.h>
34
35
#ifdef __cplusplus
36
}
37
#endif
38
39
class
dlink
;
40
class
dlist
;
41
class
dhashtab
;
42
typedef
int (*
CFN
)(
dlink
*,
dlink
*);
43
44
enum
DlGetType
45
{
46
DlGetMin
,
47
DlGetMax
48
};
49
50
class
dlist
{
51
friend
class
dhashtab
;
52
dlink
*
head
;
// head of list
53
int
cnt;
54
CFN
CmpFn;
// function to order the elements
55
public
:
56
dlist
();
// default init with NULL compare func
57
dlist
(
CFN
);
58
virtual
~dlist
();
59
void
insert
(
dlink
*);
// insert in sorted order
60
void
prepend
(
dlink
*);
// add at beginning of list
61
void
append
(
dlink
*);
// add at end of list
62
dlink
*
remove
(
dlink
*);
// remove specified entry
63
dlink
*
first
();
// return head of list
64
dlink
*
last
();
// return tail of list
65
dlink
*
get
(
DlGetType
=
DlGetMin
);
// return and remove head or tail of list
66
void
clear
();
// remove all entries
67
int
count
();
68
int
IsMember
(
dlink
*);
69
virtual
void
print
();
70
virtual
void
print
(FILE *);
71
virtual
void
print
(
int
);
72
};
73
74
enum
DlIterOrder
75
{
76
DlAscending
,
77
DlDescending
78
};
79
80
class
dlist_iterator
{
81
dlist
*cdlist;
// current dlist
82
dlink
*cdlink;
// current dlink
83
DlIterOrder
order;
// iteration order
84
public
:
85
dlist_iterator
(
dlist
&,
DlIterOrder
=
DlAscending
);
86
dlink
*
operator()
();
// return next object or 0.
87
// Does *not* support safe deletion
88
// of currently returned entry. See the
89
// comment below for more explanation.
90
};
91
92
class
dlink
{
// objects are derived from this class
93
friend
class
dlist
;
94
friend
class
dlist_iterator
;
95
dlink
*next;
96
dlink
*prev;
97
98
public
:
99
dlink
();
100
void
clear
() { next = prev =
NULL
; };
101
int
is_linked
() {
return
next !=
NULL
; };
102
virtual
~dlink
();
103
virtual
void
print
();
104
virtual
void
print
(FILE *);
105
virtual
void
print
(
int
);
106
};
107
108
#endif
/* _UTIL_DLIST_H_ */
dhashtab
Definition:
dhash.h:45
dlink
Definition:
dlist.h:92
dlink::clear
void clear()
Definition:
dlist.h:100
dlink::~dlink
virtual ~dlink()
Definition:
dlist.cc:300
dlink::dlink
dlink()
Definition:
dlist.cc:294
dlink::is_linked
int is_linked()
Definition:
dlist.h:101
dlink::print
virtual void print()
Definition:
dlist.cc:302
dlist_iterator
Definition:
dlist.h:80
dlist_iterator::dlist_iterator
dlist_iterator(dlist &, DlIterOrder=DlAscending)
Definition:
dlist.cc:257
dlist_iterator::operator()
dlink * operator()()
Definition:
dlist.cc:264
dlist
Definition:
dlist.h:50
dlist::first
dlink * first()
Definition:
dlist.cc:184
dlist::~dlist
virtual ~dlist()
Definition:
dlist.cc:62
dlist::dlist
dlist()
Definition:
dlist.cc:48
dlist::count
int count()
Definition:
dlist.cc:212
dlist::insert
void insert(dlink *)
Definition:
dlist.cc:70
dlist::print
virtual void print()
Definition:
dlist.cc:232
dlist::clear
void clear()
Definition:
dlist.cc:202
dlist::last
dlink * last()
Definition:
dlist.cc:189
dlist::remove
dlink * remove(dlink *)
Definition:
dlist.cc:159
dlist::get
dlink * get(DlGetType=DlGetMin)
Definition:
dlist.cc:194
dlist::IsMember
int IsMember(dlink *)
Definition:
dlist.cc:217
dlist::prepend
void prepend(dlink *)
Definition:
dlist.cc:115
dlist::append
void append(dlink *)
Definition:
dlist.cc:138
CFN
int(* CFN)(dlink *, dlink *)
Definition:
dlist.h:42
DlIterOrder
DlIterOrder
Definition:
dlist.h:75
DlDescending
@ DlDescending
Definition:
dlist.h:77
DlAscending
@ DlAscending
Definition:
dlist.h:76
DlGetType
DlGetType
Definition:
dlist.h:45
DlGetMin
@ DlGetMin
Definition:
dlist.h:46
DlGetMax
@ DlGetMax
Definition:
dlist.h:47
head
PROC * head
Definition:
util.c:73
NULL
#define NULL
Definition:
voltypes.h:44
Generated by
1.9.4