"Fossies" - the Fresh Open Source Software Archive

Member "coda-6.9.5/coda-src/util/rec_smolist.h" (23 May 2003, 3209 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_smolist.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  * rec_smolist.h -- Specification of a recoverable singly-linked list type 
   29  * where list elements can be on only one list at a time.
   30  *
   31  * NOTE (Satya, 5/31/95)
   32  * ---------------------
   33  * The files util/rec_smolist.[ch] were originally called vol/recolist.[ch].
   34  * The original data structures  recolink and recolist are now
   35  * called rec_smolink and rec_smolist (for "small" olist and olink).   
   36  * No functional code changes have been made --- just systematic renaming.
   37  * 
   38  * This change was made to reduce confusion with rec_olist and rec_olink.
   39  * The rec_smo* data structures are very similar to the rec_o* data structures
   40  * except that the recoverable structures are smaller.  
   41  * rec_smolist occupies the size of one long  (pointer to the last element)
   42  * while rec_olist is 12 bytes long.  
   43  * These data structures were defined as part of a fix to the 
   44  * server a long time ago, avoiding re-initialization.
   45  * rec_smolist was designed to convert each volume's vnode array from an
   46  * array of pointers (each to a single vnode) to an array of lists of
   47  * vnodes without having to reinitialize the servers.  It is now
   48  * possible to have multiple vnodes with the same vnode number because
   49  * resolution can recreate a previously deleted vnode. 
   50  *
   51  */
   52 
   53 #ifndef _UTIL_REC_SMOLIST_H_
   54 #define _UTIL_REC_SMOLIST_H_ 1
   55 
   56 #ifdef __cplusplus
   57 extern "C" {
   58 #endif
   59 
   60 #include <stdio.h>
   61 
   62 #ifdef __cplusplus
   63 }
   64 #endif
   65 
   66 
   67 
   68 class rec_smolist;
   69 class rec_smolist_iterator;
   70 struct rec_smolink;
   71 
   72 
   73 class rec_smolist {
   74     friend class rec_smolist_iterator;
   75     struct rec_smolink *last;       // last->next is head of list
   76 
   77   public:
   78     rec_smolist();
   79     ~rec_smolist();
   80     void insert(struct rec_smolink *);  // add at head of list
   81     void append(struct rec_smolink *);  // add at tail of list
   82     struct rec_smolink *remove(struct rec_smolink *); // remove specified entry
   83     struct rec_smolink *get(void);  // return and remove head of list
   84     int IsEmpty(void);      // 1 if list is empty
   85     void print(void);
   86     void print(FILE *);
   87     void print(int);
   88 };
   89 
   90 
   91 class rec_smolist_iterator {
   92     rec_smolist *clist;     // current olist
   93     struct rec_smolink *clink;  // current olink
   94     struct rec_smolink *nlink;  // next olink (in case they remove the object)
   95     
   96   public:
   97     rec_smolist_iterator(rec_smolist&);
   98     rec_smolink *operator()();  // return next object or 0
   99                                 // Support safe deletion of currently
  100                                 // returned entry.  See dlist.h also.
  101 };
  102 
  103 
  104 struct rec_smolink {
  105     struct rec_smolink *next;
  106 };
  107 void rec_smolink_print(struct rec_smolink *l, int fd);
  108 
  109 #endif /* _UTIL_REC_SMOLIST_H_ */