Panda3D
primeNumberGenerator.h
1 // Filename: primeNumberGenerator.h
2 // Created by: drose (22Mar01)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef PRIMENUMBERGENERATOR_H
16 #define PRIMENUMBERGENERATOR_H
17 
18 #include "dcbase.h"
19 
20 #ifdef WITHIN_PANDA
21 // We only have the vector_int header file if we're compiling this
22 // package within the normal Panda environment.
23 #include "vector_int.h"
24 
25 #else
26 typedef vector<int> vector_int;
27 #endif
28 
29 ////////////////////////////////////////////////////////////////////
30 // Class : PrimeNumberGenerator
31 // Description : This class generates a table of prime numbers, up to
32 // the limit of an int. For a given integer n, it will
33 // return the nth prime number. This will involve a
34 // recompute step only if n is greater than any previous
35 // n.
36 ////////////////////////////////////////////////////////////////////
38 public:
40 
41  int operator [] (int n);
42 
43 private:
44  typedef vector_int Primes;
45  Primes _primes;
46 };
47 
48 #endif
This class generates a table of prime numbers, up to the limit of an int.
int operator[](int n)
Returns the nth prime number.