TPIE

2362a60
prime.h
Go to the documentation of this file.
1 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
2 // vi:set ts=4 sts=4 sw=4 noet :
3 // Copyright 2008, The TPIE development team
4 //
5 // This file is part of TPIE.
6 //
7 // TPIE is free software: you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License as published by the
9 // Free Software Foundation, either version 3 of the License, or (at your
10 // option) any later version.
11 //
12 // TPIE is distributed in the hope that it will be useful, but WITHOUT ANY
13 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 // License for more details.
16 //
17 // You should have received a copy of the GNU Lesser General Public License
18 // along with TPIE. If not, see <http://www.gnu.org/licenses/>
19 #ifndef __TPIE_PRIME_H__
20 #define __TPIE_PRIME_H__
21 #include <tpie/array.h>
22 #include <tpie/util.h>
23 
28 namespace tpie {
29 
34 void init_prime();
35 
40 void finish_prime();
41 
48 bool is_prime(size_type i);
49 
50 typedef uint64_t hash_type;
51 
58 hash_type prime_hash(const std::string & s);
59 
65 size_t next_prime(size_t i);
66 }
67 
68 #endif //__TPIE_PRIME_H__
bool is_prime(size_type i)
Check if i is a prime.
hash_type prime_hash(const std::string &s)
Calculate a fairly good string hash based on prime numbers.
Generic internal array with known memory requirements.
size_t next_prime(size_t i)
Get next prime.
void finish_prime()
Used by tpie_finish to deinitialize the prime number database.
Miscellaneous utility functions.
void init_prime()
Used by tpie_init to initialize the prime number database.