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

dictionary.h

Go to the documentation of this file.
00001 #ifndef TYPE_T_dictionary_TYPE
00002 #define TYPE_T_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 _TYPE_T_dictionary_binding {
00015     struct _TYPE_T_dictionary_binding *next;       /* PRIVATE */
00016     char *key;                                     /* READ-ONLY */
00017     TYPE_T value;
00018 } TYPE_T_dictionary_binding;
00019 
00020 typedef struct _TYPE_T_dictionary {                /* PRIVATE */
00021     int size;
00022     TYPE_T_dictionary_binding **slots;
00023 } *TYPE_T_dictionary;
00024 
00025 /*
00026  *    TYPE_T_dictionary TYPE_T_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  *                 TYPE_T_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 TYPE_T_dictionary TYPE_T_dictionary_Create(/* int size */);
00038 
00039 /*
00040  *    void TYPE_T_dictionary_Destroy(TYPE_T_dictionary d):
00041  *        Requires: d is a non-destroyed TYPE_T_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  *                 TYPE_T_dictionary_Enumerate.
00048  */
00049 
00050 extern void TYPE_T_dictionary_Destroy(/* TYPE_T_dictionary d */);
00051 
00052 /*
00053  *    void TYPE_T_dictionary_Enumerate(TYPE_T_dictionary d; void (*proc)()):
00054  *        Requires: proc is a void procedure taking 1 argument, a
00055  *                  TYPE_T_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 TYPE_T_dictionary_Enumerate(/* TYPE_T_dictionary d, 
00064                                            void (*proc)() */);
00065 
00066 /*
00067  *    TYPE_T_dictionary_binding *TYPE_T_dictionary_Lookup(TYPE_T_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 TYPE_T_dictionary_binding *TYPE_T_dictionary_Lookup(/* d, key */);
00075 
00076 /*
00077  *    TYPE_T_dictionary_binding *TYPE_T_dictionary_Define(TYPE_T_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 TYPE_T_dictionary_binding *TYPE_T_dictionary_Define();
00093 
00094 /*
00095  *    void TYPE_T_dictionary_Delete(TYPE_T_dictionary d,
00096  *                                  TYPE_T_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 TYPE_T_dictionary_Delete();
00105 
00106 #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