~ubuntu-branches/ubuntu/lucid/igraph/lucid

« back to all changes in this revision

Viewing changes to src/bliss_eqrefhash.hh

  • Committer: Bazaar Package Importer
  • Author(s): Mathieu Malaterre
  • Date: 2009-11-16 18:12:42 UTC
  • Revision ID: james.westby@ubuntu.com-20091116181242-mzv9p5fz9uj57xd1
Tags: upstream-0.5.3
ImportĀ upstreamĀ versionĀ 0.5.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
Copyright (C) 2003-2006 Tommi Junttila
 
3
 
 
4
 This program is free software; you can redistribute it and/or modify
 
5
 it under the terms of the GNU General Public License version 2
 
6
 as published by the Free Software Foundation.
 
7
 
 
8
 This program is distributed in the hope that it will be useful,
 
9
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 GNU General Public License for more details.
 
12
 
 
13
 You should have received a copy of the GNU General Public License
 
14
 along with this program; if not, write to the Free Software
 
15
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 
16
*/
 
17
 
 
18
/* FSF address fixed in the above notice on 1 Oct 2009 by Tamas Nepusz */
 
19
 
 
20
#ifndef BLISS_EQREFHASH_HH
 
21
#define BLISS_EQREFHASH_HH
 
22
 
 
23
#include <vector>
 
24
 
 
25
#define EqrefHash BuzzHash
 
26
//#define EqrefHash PerfectHash
 
27
 
 
28
namespace igraph {
 
29
 
 
30
class BuzzHash
 
31
{
 
32
protected:
 
33
  unsigned int h;
 
34
public:
 
35
  void reset() {h = 0; }
 
36
  void update(unsigned int);
 
37
  int cmp(const BuzzHash &other);
 
38
  bool is_lt(const BuzzHash &other) {return(cmp(other) < 0); }
 
39
  bool is_le(const BuzzHash &other) {return(cmp(other) <= 0); }
 
40
  bool is_equal(const BuzzHash &other) {return(cmp(other) == 0); }
 
41
};
 
42
 
 
43
class PerfectHash
 
44
{
 
45
protected:
 
46
  std::vector<unsigned int> h;
 
47
public:
 
48
  void reset() {h.clear(); }
 
49
  void update(unsigned int i) {h.push_back(i); }
 
50
  int cmp(const PerfectHash &other);
 
51
  bool is_lt(const PerfectHash &other) {return(cmp(other) < 0); }
 
52
  bool is_le(const PerfectHash &other) {return(cmp(other) <= 0); }
 
53
  bool is_equal(const PerfectHash &other) {return(cmp(other) == 0); }
 
54
};
 
55
 
 
56
}
 
57
 
 
58
#endif