Jabber WindowGram Client (JWGC)

Introduction Screenshots Installation Downloads
Documentation Browse Source Resources Project Site

Stable Version
-none-

Latest Version
beta5



Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

int_dictionary.h

Go to the documentation of this file.
00001 #ifndef int_dictionary_TYPE
00002 #define int_dictionary_TYPE
00003 
00004 /*
00005  *      Copyright (c) 1989 by the Massachusetts Institute of Technology.
00006  *      For copying and distribution information, see the file
00007  *      "mit-copyright.h".
00008  *
00009  *      Modified for jwgc by Daniel Henninger.
00010  */
00011 
00012 #include "mit-copyright.h"
00013 
00014 typedef struct _int_dictionary_binding {
00015     struct _int_dictionary_binding *next;       /* PRIVATE */
00016     char *key;                                     /* READ-ONLY */
00017     int value;
00018 } int_dictionary_binding;
00019 
00020 typedef struct _int_dictionary {                /* PRIVATE */
00021     int size;
00022     int_dictionary_binding **slots;
00023 } *int_dictionary;
00024 
00025 /*
00026  *    int_dictionary int_dictionary_Create(int size):
00027  *        Requires: size > 0
00028  *        Effects: Returns a new empty dictionary containing no bindings.
00029  *                 The returned dictionary must be destroyed using
00030  *                 int_dictionary_Destroy.  Size is a time vs space
00031  *                 parameter.  For this implementation, space used is
00032  *                 proportional to size and time used is proportional
00033  *                 to number of bindings divided by size.  It is preferable
00034  *                 that size is a prime number.
00035  */
00036 
00037 extern int_dictionary int_dictionary_Create(/* int size */);
00038 
00039 /*
00040  *    void int_dictionary_Destroy(int_dictionary d):
00041  *        Requires: d is a non-destroyed int_dictionary
00042  *        Modifies: d
00043  *        Effects: Destroys dictionary d freeing up the space it consumes.
00044  *                 Dictionary d should never be referenced again.  Note that
00045  *                 free is NOT called on the values of the bindings.  If
00046  *                 this is needed, the client must do this first using
00047  *                 int_dictionary_Enumerate.
00048  */
00049 
00050 extern void int_dictionary_Destroy(/* int_dictionary d */);
00051 
00052 /*
00053  *    void int_dictionary_Enumerate(int_dictionary d; void (*proc)()):
00054  *        Requires: proc is a void procedure taking 1 argument, a
00055  *                  int_dictionary_binding pointer, which does not
00056  *                  make any calls using dictionary d.
00057  *        Effects: Calls proc once with each binding in dictionary d.
00058  *                 Order of bindings passed is undefined.  Note that
00059  *                 only the value field of the binding should be considered
00060  *                 writable by proc.
00061  */
00062 
00063 extern void int_dictionary_Enumerate(/* int_dictionary d, 
00064                                            void (*proc)() */);
00065 
00066 /*
00067  *    int_dictionary_binding *int_dictionary_Lookup(int_dictionary d,
00068  *                                                        char *key):
00069  *        Effects: If key is not bound in d, returns 0.  Othersize,
00070  *                 returns a pointer to the binding that binds key.
00071  *                 Note the access restrictions on bindings...
00072  */
00073 
00074 extern int_dictionary_binding *int_dictionary_Lookup(/* d, key */);
00075 
00076 /*
00077  *    int_dictionary_binding *int_dictionary_Define(int_dictionary d,
00078  *                                            char *key,
00079  *                                            int *already_existed):
00080  *        Modifies: d
00081  *        Effects: If key is bound in d, returns a pointer to the binding
00082  *                 that binds key.  Otherwise, adds a binding of key to
00083  *                 d and returns its address.  If already_existed is non-zero
00084  *                 then *already_existed is set to 0 if key was not
00085  *                 previously bound in d and 1 otherwise.
00086  *                 Note the access restrictions on bindings...  Note also
00087  *                 that the value that key is bounded to if a binding is
00088  *                 created is undefined.  The caller should set the value
00089  *                 in this case.
00090  */
00091 
00092 extern int_dictionary_binding *int_dictionary_Define();
00093 
00094 /*
00095  *    void int_dictionary_Delete(int_dictionary d,
00096  *                                  int_dictionary_binding *b):
00097  *        Requires: *b is a binding in d.
00098  *        Modifies: d
00099  *        Effects: Removes the binding *b from d.  Note that if 
00100  *                 b->value needs to be freed, it should be freed
00101  *                 before making this call.
00102  */
00103 
00104 extern void int_dictionary_Delete();
00105 
00106 #endif
00107 #ifndef int_dictionary_TYPE
00108 #define int_dictionary_TYPE
00109 
00110 /*
00111  *      Copyright (c) 1989 by the Massachusetts Institute of Technology.
00112  *      For copying and distribution information, see the file
00113  *      "mit-copyright.h".
00114  *
00115  *      Modified for jwgc by Daniel Henninger.
00116  */
00117 
00118 #include "mit-copyright.h"
00119 
00120 typedef struct _int_dictionary_binding {
00121     struct _int_dictionary_binding *next;       /* PRIVATE */
00122     char *key;                                     /* READ-ONLY */
00123     int value;
00124 } int_dictionary_binding;
00125 
00126 typedef struct _int_dictionary {                /* PRIVATE */
00127     int size;
00128     int_dictionary_binding **slots;
00129 } *int_dictionary;
00130 
00131 /*
00132  *    int_dictionary int_dictionary_Create(int size):
00133  *        Requires: size > 0
00134  *        Effects: Returns a new empty dictionary containing no bindings.
00135  *                 The returned dictionary must be destroyed using
00136  *                 int_dictionary_Destroy.  Size is a time vs space
00137  *                 parameter.  For this implementation, space used is
00138  *                 proportional to size and time used is proportional
00139  *                 to number of bindings divided by size.  It is preferable
00140  *                 that size is a prime number.
00141  */
00142 
00143 extern int_dictionary int_dictionary_Create(/* int size */);
00144 
00145 /*
00146  *    void int_dictionary_Destroy(int_dictionary d):
00147  *        Requires: d is a non-destroyed int_dictionary
00148  *        Modifies: d
00149  *        Effects: Destroys dictionary d freeing up the space it consumes.
00150  *                 Dictionary d should never be referenced again.  Note that
00151  *                 free is NOT called on the values of the bindings.  If
00152  *                 this is needed, the client must do this first using
00153  *                 int_dictionary_Enumerate.
00154  */
00155 
00156 extern void int_dictionary_Destroy(/* int_dictionary d */);
00157 
00158 /*
00159  *    void int_dictionary_Enumerate(int_dictionary d; void (*proc)()):
00160  *        Requires: proc is a void procedure taking 1 argument, a
00161  *                  int_dictionary_binding pointer, which does not
00162  *                  make any calls using dictionary d.
00163  *        Effects: Calls proc once with each binding in dictionary d.
00164  *                 Order of bindings passed is undefined.  Note that
00165  *                 only the value field of the binding should be considered
00166  *                 writable by proc.
00167  */
00168 
00169 extern void int_dictionary_Enumerate(/* int_dictionary d, 
00170                                            void (*proc)() */);
00171 
00172 /*
00173  *    int_dictionary_binding *int_dictionary_Lookup(int_dictionary d,
00174  *                                                        char *key):
00175  *        Effects: If key is not bound in d, returns 0.  Othersize,
00176  *                 returns a pointer to the binding that binds key.
00177  *                 Note the access restrictions on bindings...
00178  */
00179 
00180 extern int_dictionary_binding *int_dictionary_Lookup(/* d, key */);
00181 
00182 /*
00183  *    int_dictionary_binding *int_dictionary_Define(int_dictionary d,
00184  *                                            char *key,
00185  *                                            int *already_existed):
00186  *        Modifies: d
00187  *        Effects: If key is bound in d, returns a pointer to the binding
00188  *                 that binds key.  Otherwise, adds a binding of key to
00189  *                 d and returns its address.  If already_existed is non-zero
00190  *                 then *already_existed is set to 0 if key was not
00191  *                 previously bound in d and 1 otherwise.
00192  *                 Note the access restrictions on bindings...  Note also
00193  *                 that the value that key is bounded to if a binding is
00194  *                 created is undefined.  The caller should set the value
00195  *                 in this case.
00196  */
00197 
00198 extern int_dictionary_binding *int_dictionary_Define();
00199 
00200 /*
00201  *    void int_dictionary_Delete(int_dictionary d,
00202  *                                  int_dictionary_binding *b):
00203  *        Requires: *b is a binding in d.
00204  *        Modifies: d
00205  *        Effects: Removes the binding *b from d.  Note that if 
00206  *                 b->value needs to be freed, it should be freed
00207  *                 before making this call.
00208  */
00209 
00210 extern void int_dictionary_Delete();
00211 
00212 #endif


Last updated at Tue Dec 18 21:07:42 PST 2007. This site and project hosted by...SourceForge.net Logo
Source Perspective by Fisheye