1 /***************************************************************************
2 primenumber.h - class primenumber
4 begin : Tue Nov 27 16:40:42 CET 2001
5 copyright : (C) 2001 by Sebastian Stein
6 email : seb.kde@hpfsc.de
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
21 #include <qvaluevector.h>
23 typedef QValueVector
<uint
> UnsignedIntArray
;
25 /** Class to handle prime numbers.
26 * The prime numbers are stored in a static vector, so that different instances
27 * can use them. Each time a higher prime number is needed, the new found prime
28 * number is stored in the vector. To check if a given number is a prime number
29 * this vector is scanned and if needed new prime numbers are generated. This
30 * algorithm should reduce calculation time and speed up every program using
31 * this prime number class.
32 * \author Sebastian Stein */
42 /** returns wether the given number is a prime number */
43 short isPrimeNumber(uint number
);
45 /** returns the next prime number */
46 unsigned int get_next();
48 /** returns the first prime number */
49 unsigned int get_first() const;
51 /** return the last known prime number */
52 unsigned int get_last() const;
54 /** returns the current prime number */
55 unsigned int get_current() const;
57 /** moves the internal pointer to the first prime number */
60 /** moves the internal pointer to the last prime number */
63 /** moves the internal pointer to the next prime number */
66 /** moves the internal pointer to the previous prime number */
69 /** Displays all known prime numbers, mainly used for debugging. */
72 /** a vector storing all known prime numbers, access for all objects;
73 * we are using the vector<T> template; so we do not have to think
74 * about dynamic mem manipulation */
75 static UnsignedIntArray prim_vector
;
77 /** current selected prime number */
78 UnsignedIntArray::iterator current_pos
;
80 /** finds next prime number and adds it to the vector */