Coda Distributed File System
rec_dhash.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
9This code is distributed "AS IS" without warranty of any kind under
10the terms of the GNU General Public Licence Version 2, as shown in the
11file LICENSE. The technical and financial contributors to Coda are
12listed in the file CREDITS.
13
14 Additional copyrights
15 none currently
16
17#*/
18
19/*
20 *
21 * dhash.h -- Specification of recoverable hash-table type where each bucket
22 * is a doubly-linked list (a dlist).
23 *
24 */
25
26#ifndef _UTIL_REC_DHTAB_H_
27#define _UTIL_REC_DHTAB_H_ 1
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33#include <stdio.h>
34
35#ifdef __cplusplus
36}
37#endif
38
39#include "dhash.h"
40#include "rec_dlist.h"
41#include "rvmlib.h"
42
43class rec_dlink;
44class rec_dhashtab;
46typedef int (*RHFN)(void *);
47
50 int sz; // size of the array
51 rec_dlist *a; // array of dlists
52 RHFN hfn; // the hash function
53 int cnt;
54
55public:
56 void *operator new(size_t) REQUIRES_TRANSACTION;
57 void operator delete(void *) REQUIRES_TRANSACTION;
58
59 rec_dhashtab(int, RHFN, RCFN = 0);
60 rec_dhashtab(rec_dhashtab &); // not supported!
62 int operator=(rec_dhashtab &); // not supported!
65 void SetHFn(RHFN);
66 void SetCmpFn(RCFN);
67 void insert(void *,
68 rec_dlink *) REQUIRES_TRANSACTION; /* add in sorted order */
69 void prepend(void *,
70 rec_dlink *) REQUIRES_TRANSACTION; /* add at head of list */
71 void append(void *,
72 rec_dlink *) REQUIRES_TRANSACTION; /* add at tail of list */
73 rec_dlink *remove(void *, rec_dlink *)
74 REQUIRES_TRANSACTION; /* remove specified entry */
75 rec_dlink *first(); /* return first element of table */
76 rec_dlink *last(); /* return last element of table */
78 REQUIRES_TRANSACTION; // return and remove head or tail of list
79
80 int count();
81 int IsMember(void *, rec_dlink *);
82 int bucket(void *); // returns bucket number of key
83 /*virtual*/ void print();
84 /*virtual*/ void print(FILE *);
85 /*virtual*/ void print(int);
86};
87
88/*enum DhIterOrder { DhAscending, DhDescending };*/
89
91 rec_dhashtab *chashtab; // current dhashtab
92 int allbuckets; // iterate over all or single bucket
93 int cbucket; // current bucket
94 rec_dlist_iterator *nextlink; // current dlist iterator
95 DhIterOrder order; // iteration order
96public:
98 void * = (void *)-1);
100 rec_dlink *operator()(); // return next object or 0
101};
102
103#endif /* _UTIL_REC_DHTAB_H_ */
Definition: rec_dhash.h:90
~rec_dhashtab_iterator()
Definition: rec_dhash.cc:260
rec_dlink * operator()()
Definition: rec_dhash.cc:265
Definition: rec_dhash.h:48
void append(void *, rec_dlink *) REQUIRES_TRANSACTION
Definition: rec_dhash.cc:155
rec_dlink * remove(void *, rec_dlink *) REQUIRES_TRANSACTION
Definition: rec_dhash.cc:163
~rec_dhashtab()
Definition: rec_dhash.cc:63
void insert(void *, rec_dlink *) REQUIRES_TRANSACTION
Definition: rec_dhash.cc:139
rec_dlink * last()
Definition: rec_dhash.cc:184
rec_dlink * get(void *, DlGetType=DlGetMin) REQUIRES_TRANSACTION
Definition: rec_dhash.cc:198
void prepend(void *, rec_dlink *) REQUIRES_TRANSACTION
Definition: rec_dhash.cc:147
int operator=(rec_dhashtab &)
Definition: rec_dhash.cc:100
void SetCmpFn(RCFN)
Definition: rec_dhash.cc:133
friend class rec_dhashtab_iterator
Definition: rec_dhash.h:49
int IsMember(void *, rec_dlink *)
Definition: rec_dhash.cc:213
void DeInit() REQUIRES_TRANSACTION
Definition: rec_dhash.cc:106
void print()
Definition: rec_dhash.cc:224
void SetHFn(RHFN)
Definition: rec_dhash.cc:125
rec_dhashtab(int, RHFN, RCFN=0)
Definition: rec_dhash.cc:58
rec_dlink * first()
Definition: rec_dhash.cc:170
int bucket(void *)
Definition: rec_dhash.cc:219
void Init(int, RHFN, RCFN) REQUIRES_TRANSACTION
Definition: rec_dhash.cc:68
int count()
Definition: rec_dhash.cc:208
Definition: rec_dlist.h:85
Definition: rec_dlist.h:49
#define REQUIRES_TRANSACTION
Definition: coda_tsa.h:107
DhIterOrder
Definition: dhash.h:75
@ DhAscending
Definition: dhash.h:76
DlGetType
Definition: dlist.h:45
@ DlGetMin
Definition: dlist.h:46
int(* RHFN)(void *)
Definition: rec_dhash.h:46
int(* RCFN)(rec_dlink *, rec_dlink *)
Definition: rec_dlist.h:45