Coda Distributed File System
rec_ohash.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 * rec_ohash.h -- Specification of hash-table type where each bucket is a recoverable
22 * singly-linked list (a rec_olist).
23 *
24 */
25
26#ifndef _UTIL_REC_OHASH_H_
27#define _UTIL_REC_OHASH_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 "ohash.h"
40#include "rec_olist.h"
41#include "rvmlib.h"
42
43class rec_ohashtab;
45typedef int (*RHFN)(const void *);
46
49 int sz; /* size of the array */
50 rec_olist *a; /* array of olists */
51 RHFN hfn; /* the hash function */
52 int cnt;
53
54public:
55 void *operator new(size_t) REQUIRES_TRANSACTION;
56 void operator delete(void *) REQUIRES_TRANSACTION;
57
58 rec_ohashtab(int, RHFN);
59 rec_ohashtab(rec_ohashtab &); // not supported!
61 int operator=(rec_ohashtab &); /* not supported! */
64 void SetHFn(RHFN);
65
66 void insert(void *,
67 rec_olink *) REQUIRES_TRANSACTION; /* add at head of list */
68 void append(void *,
69 rec_olink *) REQUIRES_TRANSACTION; /* add at tail of list */
70 rec_olink *remove(void *, rec_olink *)
71 REQUIRES_TRANSACTION; /* remove specified entry */
72 rec_olink *first(); /* return first element of table */
73 rec_olink *last(); /* return last element of table */
74 rec_olink *
75 get(void *) REQUIRES_TRANSACTION; /* return and remove head of list */
76
77 int count();
78 int IsMember(void *, rec_olink *);
79 int bucket(const void *); /* returns bucket number of key */
80 /*virtual*/ void print();
81 /*virtual*/ void print(FILE *);
82 /*virtual*/ void print(int);
83};
84
86 rec_ohashtab *chashtab; /* current rec_ohashtab */
87 int allbuckets; /* iterate over all or single bucket */
88 int cbucket; /* current bucket */
89
90protected:
91 rec_olist_iterator *nextlink; /* current olist iterator */
92
93public:
94 rec_ohashtab_iterator(rec_ohashtab &, const void * = (void *)-1);
96 void Reset();
97 rec_olink *operator()(); /* return next object or 0 */
98};
99
100#endif /* _UTIL_REC_OHASH_H_ */
Definition: rec_ohash.h:85
rec_olist_iterator * nextlink
Definition: rec_ohash.h:91
~rec_ohashtab_iterator()
Definition: rec_ohash.cc:243
rec_olink * operator()()
Definition: rec_ohash.cc:248
void Reset()
Definition: rec_ohash.cc:235
Definition: rec_ohash.h:47
int operator=(rec_ohashtab &)
Definition: rec_ohash.cc:116
void Init(int, RHFN) REQUIRES_TRANSACTION
Definition: rec_ohash.cc:72
rec_olink * get(void *) REQUIRES_TRANSACTION
Definition: rec_ohash.cc:181
void append(void *, rec_olink *) REQUIRES_TRANSACTION
Definition: rec_ohash.cc:138
rec_ohashtab(int, RHFN)
Definition: rec_ohash.cc:62
void insert(void *, rec_olink *) REQUIRES_TRANSACTION
Definition: rec_ohash.cc:130
rec_olink * last()
Definition: rec_ohash.cc:167
rec_olink * remove(void *, rec_olink *) REQUIRES_TRANSACTION
Definition: rec_ohash.cc:146
~rec_ohashtab()
Definition: rec_ohash.cc:67
friend class rec_ohashtab_iterator
Definition: rec_ohash.h:48
int IsMember(void *, rec_olink *)
Definition: rec_ohash.cc:193
rec_olink * first()
Definition: rec_ohash.cc:153
int bucket(const void *)
Definition: rec_ohash.cc:199
void SetHFn(RHFN)
Definition: rec_ohash.cc:123
void DeInit() REQUIRES_TRANSACTION
Definition: rec_ohash.cc:98
int count()
Definition: rec_ohash.cc:188
void print()
Definition: rec_ohash.cc:204
Definition: rec_olist.h:77
Definition: rec_olist.h:46
#define REQUIRES_TRANSACTION
Definition: coda_tsa.h:107
int(* RHFN)(const void *)
Definition: rec_ohash.h:45