3 * Iterate over small primes efficiently
5 * (c) 2007 Straylight/Edgeware
8 /*----- Licensing notice --------------------------------------------------*
10 * This file is part of Catacomb.
12 * Catacomb is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Library General Public License as
14 * published by the Free Software Foundation; either version 2 of the
15 * License, or (at your option) any later version.
17 * Catacomb is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Library General Public License for more details.
22 * You should have received a copy of the GNU Library General Public
23 * License along with Catacomb; if not, write to the Free
24 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
28 #ifndef CATACOMB_PRIMEITER_H
29 #define CATACOMB_PRIMEITER_H
35 /*----- Header files ------------------------------------------------------*/
37 #ifndef CATACOMB_GRAND_H
45 /*----- Data structures ---------------------------------------------------*/
47 typedef struct primeiter {
62 /*----- Functions provided ------------------------------------------------*/
64 /* --- @primeiter_create@ --- *
66 * Arguments: @primeiter *pi@ = pointer to an iterator structure
67 * @mp *start@ = where to start
71 * Use: Initializes a prime iterator. The first output will be the
72 * smallest prime not less than @start@.
75 extern void primeiter_create(primeiter */*pi*/, mp */*start*/);
77 /* --- @primeiter_destroy@ --- *
79 * Arguments: @primeiter *pi@ = pointer to iterator structure
83 * Use: Frees up an iterator structure when it's no longer wanted.
86 void primeiter_destroy(primeiter */*pi*/);
88 /* --- @primeiter_next@ --- *
90 * Arguments: @primeiter *pi@ = pointer to an iterator structure
91 * @mp *d@ = fake destination
93 * Returns: The next prime number from the iterator.
95 * Use: Returns a new prime number.
98 mp *primeiter_next(primeiter */*pi*/, mp */*d*/);
100 /*----- That's all, folks -------------------------------------------------*/