• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*---------------------------------------------------------------------------*
2  *  astar_pphash.h  *
3  *                                                                           *
4  *  Copyright 2007, 2008 Nuance Communciations, Inc.                               *
5  *                                                                           *
6  *  Licensed under the Apache License, Version 2.0 (the 'License');          *
7  *  you may not use this file except in compliance with the License.         *
8  *                                                                           *
9  *  You may obtain a copy of the License at                                  *
10  *      http://www.apache.org/licenses/LICENSE-2.0                           *
11  *                                                                           *
12  *  Unless required by applicable law or agreed to in writing, software      *
13  *  distributed under the License is distributed on an 'AS IS' BASIS,        *
14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
15  *  See the License for the specific language governing permissions and      *
16  *  limitations under the License.                                           *
17  *                                                                           *
18  *---------------------------------------------------------------------------*/
19 
20 #ifndef __ASTAR_PPHASH__
21 #define __ASTAR_PPHASH__
22 
23 #define FSH_SUCCESS       0
24 #define FSH_KEY_OCCUPIED  1
25 #define FSH_NO_SUCH_KEY   2
26 #define FSH_HASHSIZE     37
27 #define FSH_NULL 0
28 
29 #include "astar.h"
30 
31 /**
32  * The FixedSizeHash is a hash that does not grow in size.
33  * In each bin there are a number of elements, which are maintained
34  * via a linked list.
35  * This is used to find out whether a path with the same word history
36  * as the one being expanded has already been search.  If yes, we can
37  * abort this one.
38  */
39 typedef struct
40 {
41   int hashsize;
42   partial_path* items[FSH_HASHSIZE];
43   srec* rec;
44 }
45 FixedSizeHash;
46 
47 void hash_init(FixedSizeHash* hash, srec* rec);
48 int hash_del(FixedSizeHash* hash, partial_path* parp);
49 unsigned int hashfunc(partial_path* parp);
50 int compare_parp(partial_path* parp1, partial_path* parp2, srec* rec);
51 int hash_get(FixedSizeHash* hash, partial_path* parp, void** hval);
52 int hash_set(FixedSizeHash* hash, partial_path* parp);
53 
54 #endif
55