]>
Commit | Line | Data |
---|---|---|
4c2d6a70 AC |
1 | ------------------------------------------------------------------------------ |
2 | -- -- | |
3 | -- GNAT LIBRARY COMPONENTS -- | |
4 | -- -- | |
3084fecd | 5 | -- A D A . C O N T A I N E R S . P R I M E _ N U M B E R S -- |
4c2d6a70 AC |
6 | -- -- |
7 | -- S p e c -- | |
8 | -- -- | |
4b490c1e | 9 | -- Copyright (C) 2004-2020, Free Software Foundation, Inc. -- |
4c2d6a70 | 10 | -- -- |
d90e94c7 JM |
11 | -- GNAT is free software; you can redistribute it and/or modify it under -- |
12 | -- terms of the GNU General Public License as published by the Free Soft- -- | |
748086b7 | 13 | -- ware Foundation; either version 3, or (at your option) any later ver- -- |
d90e94c7 JM |
14 | -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- |
15 | -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- | |
748086b7 JJ |
16 | -- or FITNESS FOR A PARTICULAR PURPOSE. -- |
17 | -- -- | |
18 | -- As a special exception under Section 7 of GPL version 3, you are granted -- | |
19 | -- additional permissions described in the GCC Runtime Library Exception, -- | |
20 | -- version 3.1, as published by the Free Software Foundation. -- | |
21 | -- -- | |
22 | -- You should have received a copy of the GNU General Public License and -- | |
23 | -- a copy of the GCC Runtime Library Exception along with this program; -- | |
24 | -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- | |
25 | -- <http://www.gnu.org/licenses/>. -- | |
d90e94c7 JM |
26 | -- -- |
27 | -- This unit was originally developed by Matthew J Heaney. -- | |
4c2d6a70 AC |
28 | ------------------------------------------------------------------------------ |
29 | ||
d90e94c7 JM |
30 | -- This package declares the prime numbers array used to implement hashed |
31 | -- containers. Bucket arrays are always allocated with a prime-number | |
32 | -- length (computed using To_Prime below), as this produces better scatter | |
33 | -- when hash values are folded. | |
34 | ||
4c2d6a70 | 35 | package Ada.Containers.Prime_Numbers is |
009186e0 | 36 | pragma Pure; |
4c2d6a70 AC |
37 | |
38 | type Primes_Type is array (Positive range <>) of Hash_Type; | |
39 | ||
40 | Primes : constant Primes_Type := | |
41 | (53, 97, 193, 389, 769, | |
42 | 1543, 3079, 6151, 12289, 24593, | |
43 | 49157, 98317, 196613, 393241, 786433, | |
44 | 1572869, 3145739, 6291469, 12582917, 25165843, | |
45 | 50331653, 100663319, 201326611, 402653189, 805306457, | |
46 | 1610612741, 3221225473, 4294967291); | |
47 | ||
48 | function To_Prime (Length : Count_Type) return Hash_Type; | |
d90e94c7 | 49 | -- Returns the smallest value in Primes not less than Length |
4c2d6a70 AC |
50 | |
51 | end Ada.Containers.Prime_Numbers; |