"Fossies" - the Fresh Open Source Software Archive

Member "coda-6.9.5/coda-src/util/rec_dhash.h" (11 Aug 2006, 2830 Bytes) of package /linux/misc/old/coda-6.9.5.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "rec_dhash.h" see the Fossies "Dox" file reference documentation.

    1 /* BLURB gpl
    2 
    3                            Coda File System
    4                               Release 6
    5 
    6           Copyright (c) 1987-2003 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 
   22 
   23 
   24 
   25 
   26 
   27 /*
   28  *
   29  * dhash.h -- Specification of recoverable hash-table type where each bucket 
   30  * is a doubly-linked list (a dlist).
   31  *
   32  */
   33 
   34 #ifndef _UTIL_REC_DHTAB_H_
   35 #define _UTIL_REC_DHTAB_H_ 1
   36 
   37 #ifdef __cplusplus
   38 extern "C" {
   39 #endif
   40 
   41 #include <stdio.h>
   42 
   43 #ifdef __cplusplus
   44 }
   45 #endif
   46 
   47 
   48 #include "dhash.h"
   49 #include "rec_dlist.h"
   50 #include "rvmlib.h"
   51 
   52 class rec_dlink;
   53 class rec_dhashtab;
   54 class rec_dhashtab_iterator;
   55 typedef int (*RHFN)(void *);
   56 
   57 
   58 class rec_dhashtab {
   59   friend class rec_dhashtab_iterator;
   60     int sz;             // size of the array
   61     rec_dlist *a;           // array of dlists
   62     RHFN hfn;               // the hash function
   63     int cnt;
   64 
   65   public:
   66     void *operator new (size_t);
   67     void operator delete(void *);
   68 
   69     rec_dhashtab(int, RHFN, RCFN =0);
   70     rec_dhashtab(rec_dhashtab&);    // not supported!
   71     void Init(int, RHFN, RCFN); 
   72     int operator=(rec_dhashtab&);   // not supported!
   73     ~rec_dhashtab();
   74     void DeInit();
   75     void SetHFn(RHFN); 
   76     void SetCmpFn(RCFN);
   77     void insert(void *, rec_dlink *);           /* add in sorted order */ 
   78     void prepend(void *, rec_dlink *);          /* add at head of list */
   79     void append(void *, rec_dlink *);           /* add at tail of list */
   80     rec_dlink *remove(void *, rec_dlink *);     /* remove specified entry */
   81     rec_dlink *first();                     /* return first element of table */
   82     rec_dlink *last();                      /* return last element of table */
   83     rec_dlink *get(void *, DlGetType =DlGetMin); // return and remove head or tail of list
   84 
   85     int count();
   86     int IsMember(void *, rec_dlink *);
   87     int bucket(void *);         // returns bucket number of key
   88     /*virtual*/ void print();
   89     /*virtual*/ void print(FILE *);
   90     /*virtual*/ void print(int);
   91 };
   92 
   93 
   94 /*enum DhIterOrder { DhAscending, DhDescending };*/
   95 
   96 class rec_dhashtab_iterator {
   97     rec_dhashtab *chashtab;     // current dhashtab
   98     int allbuckets;             // iterate over all or single bucket
   99     int cbucket;                // current bucket
  100     rec_dlist_iterator *nextlink;   // current dlist iterator
  101     DhIterOrder order;              // iteration order
  102   public:
  103     rec_dhashtab_iterator(rec_dhashtab&, DhIterOrder =DhAscending, void * =(void *)-1);
  104     ~rec_dhashtab_iterator();
  105     rec_dlink *operator()();        // return next object or 0
  106     
  107 };
  108 
  109 #endif /* _UTIL_REC_DHTAB_H_ */