00001 /*@HEADER 00002 // *********************************************************************** 00003 // 00004 // Ifpack: Object-Oriented Algebraic Preconditioner Package 00005 // Copyright (2009) Sandia Corporation 00006 // 00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00008 // license for use of this work by or on behalf of the U.S. Government. 00009 // 00010 // This library is free software; you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as 00012 // published by the Free Software Foundation; either version 2.1 of the 00013 // License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, but 00016 // WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00023 // USA 00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00025 // 00026 // *********************************************************************** 00027 //@HEADER 00028 */ 00029 00030 #ifndef HASH_D_DH 00031 #define HASH_D_DH 00032 00033 /* todo: rehash should be implemented in Hash_dhInsert(); 00034 as of now, an error is set if the table overflows. 00035 */ 00036 00037 #include "euclid_common.h" 00038 00039 /* This should be done with templates, if this were in C++; 00040 for now, a record contains every type of entry we might 00041 need; this is a waste of memory, when one is only intersted 00042 in hashing <key, int> pairs! 00043 */ 00044 #ifdef __cplusplus 00045 extern "C" 00046 { 00047 #endif 00048 00049 typedef struct _hash_node 00050 { 00051 int iData; /* integer */ 00052 double fData; /* float */ 00053 int *iDataPtr; /* pointer to integer */ 00054 int *iDataPtr2; /* pointer to integer */ 00055 double *fDataPtr; /* pointer to float */ 00056 } HashData; 00057 00058 00059 typedef struct _hash_node_private HashRecord; 00060 00061 /* data structure for the hash table; do not directly access */ 00062 struct _hash_dh 00063 { 00064 int size; /* total slots in table */ 00065 int count; /* number of insertions in table */ 00066 int curMark; 00067 HashRecord *data; 00068 }; 00069 00070 00071 extern void Hash_dhCreate (Hash_dh * h, int size); 00072 extern void Hash_dhDestroy (Hash_dh h); 00073 extern void Hash_dhInsert (Hash_dh h, int key, HashData * data); 00074 extern HashData *Hash_dhLookup (Hash_dh h, int key); 00075 /* returns NULL if record isn't found. */ 00076 00077 extern void Hash_dhReset (Hash_dh h); 00078 extern void Hash_dhPrint (Hash_dh h, FILE * fp); 00079 00080 00081 #define HASH_1(k,size,idxOut) \ 00082 { *idxOut = k % size; } 00083 00084 #define HASH_2(k,size,idxOut) \ 00085 { \ 00086 int r = k % (size-13); \ 00087 r = (r % 2) ? r : r+1; \ 00088 *idxOut = r; \ 00089 } 00090 00091 #ifdef __cplusplus 00092 } 00093 #endif 00094 #endif
1.7.6.1