libFirm 1.20
libfirm/adt/hashset.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
00003  *
00004  * This file is part of libFirm.
00005  *
00006  * This file may be distributed and/or modified under the terms of the
00007  * GNU General Public License version 2 as published by the Free Software
00008  * Foundation and appearing in the file LICENSE.GPL included in the
00009  * packaging of this file.
00010  *
00011  * Licensees holding valid libFirm Professional Edition licenses may use
00012  * this file in accordance with the libFirm Commercial License.
00013  * Agreement provided with the Software.
00014  *
00015  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00016  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00017  * PURPOSE.
00018  */
00019 
00029 #ifdef HashSet
00030 
00031 #include <stdlib.h>
00032 
00033 #ifdef DO_REHASH
00034 #define HashSetEntry ValueType
00035 #else
00036 typedef struct HashSetEntry {
00037     ValueType data;
00038     unsigned hash;
00039 } HashSetEntry;
00040 #endif
00041 
00042 struct HashSet {
00043     HashSetEntry *entries;
00044     size_t num_buckets;
00045     size_t enlarge_threshold;
00046     size_t shrink_threshold;
00047     size_t num_elements;
00048     size_t num_deleted;
00049     int consider_shrink;
00050 #ifndef NDEBUG
00051     unsigned entries_version;
00052 #endif
00053 #ifdef ADDITIONAL_DATA
00054     ADDITIONAL_DATA
00055 #endif
00056 };
00057 
00058 #ifndef NO_ITERATOR
00059 struct HashSetIterator {
00060     HashSetEntry *current_bucket;
00061     HashSetEntry *end;
00062 #ifndef NDEBUG
00063     const struct HashSet *set;
00064     unsigned entries_version;
00065 #endif
00066 };
00067 #endif
00068 
00069 #ifdef DO_REHASH
00070 #undef HashSetEntry
00071 #endif
00072 
00073 #endif