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