00001 // Filename: primeNumberGenerator.h 00002 // Created by: drose (22Mar01) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef PRIMENUMBERGENERATOR_H 00016 #define PRIMENUMBERGENERATOR_H 00017 00018 #include "dcbase.h" 00019 00020 #ifdef WITHIN_PANDA 00021 // We only have the vector_int header file if we're compiling this 00022 // package within the normal Panda environment. 00023 #include "vector_int.h" 00024 00025 #else 00026 typedef vector<int> vector_int; 00027 #endif 00028 00029 //////////////////////////////////////////////////////////////////// 00030 // Class : PrimeNumberGenerator 00031 // Description : This class generates a table of prime numbers, up to 00032 // the limit of an int. For a given integer n, it will 00033 // return the nth prime number. This will involve a 00034 // recompute step only if n is greater than any previous 00035 // n. 00036 //////////////////////////////////////////////////////////////////// 00037 class PrimeNumberGenerator { 00038 public: 00039 PrimeNumberGenerator(); 00040 00041 int operator [] (int n); 00042 00043 private: 00044 typedef vector_int Primes; 00045 Primes _primes; 00046 }; 00047 00048 #endif