bool-array.h revision 225736
1/* This may look like C code, but it is really -*- C++ -*- */
2
3/* Simple lookup table abstraction implemented as an Iteration Number Array.
4
5   Copyright (C) 1989-1998 Free Software Foundation, Inc.
6   written by Douglas C. Schmidt (schmidt@ics.uci.edu)
7
8This file is part of GNU GPERF.
9
10GNU GPERF is free software; you can redistribute it and/or modify
11it under the terms of the GNU General Public License as published by
12the Free Software Foundation; either version 1, or (at your option)
13any later version.
14
15GNU GPERF is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18GNU General Public License for more details.
19
20You should have received a copy of the GNU General Public License
21along with GNU GPERF; see the file COPYING.  If not, write to the Free
22Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
23
24/* Define and implement a simple boolean array abstraction,
25   uses an Iteration Numbering implementation to save on initialization time. */
26
27#ifndef bool_array_h
28#define bool_array_h 1
29
30#include "trace.h"
31
32#ifdef LO_CAL
33/* If we are on a memory diet then we'll only make these use a limited
34   amount of storage space. */
35typedef unsigned short STORAGE_TYPE;
36#else
37typedef unsigned int STORAGE_TYPE;
38#endif
39
40class Bool_Array
41{
42private:
43  static STORAGE_TYPE *storage_array;    /* Initialization of the index space. */
44  static STORAGE_TYPE  iteration_number; /* Keep track of the current iteration. */
45  static unsigned int  size;             /* Keep track of array size. */
46
47public:
48       Bool_Array (void);
49      ~Bool_Array (void);
50  static void init (STORAGE_TYPE *buffer, unsigned int s);
51  static int  find (int hash_value);
52  static void reset (void);
53};
54
55#ifdef __OPTIMIZE__  /* efficiency hack! */
56
57#include <stdio.h>
58#include <string.h>
59#include "options.h"
60#define INLINE inline
61#include "bool-array.icc"
62#undef INLINE
63
64#endif
65
66#endif
67