E D R , A S I H C RSS

Full text search for "GeneratePrimes"

Generate Primes


Search BackLinks only
Display context of search results
Case-sensitive searching
  • BabyStepsSafely . . . . 19 matches
         The code that is to be refactored has existed in the system for awhile. It has undergone a couple of transformations. Initially it returned an array of int variables that are the prime numbers. When the new collection library was introduced in Java2 the interface was changed to return a List of Integer objects. Going forward the method that returns a List is the preferred method, so the method that returns an array has been marked as being deprecated for the last couple of releases. During this release the array member function will be removed. Listing1, "Class GeneratePrimes," contains the source code for both methods.
         The algorithm is quite simple. Given an array of integers starting at 2.Cross out all multiples of 2. Find the next uncrossed integer, and cross out all of its multiples. Repeat until you have passed the square root of the maximum value. This algorithm is implemented in the method generatePrimes() in Listing1. "Class GeneratePrimes,".
         pulbic class GeneratePrimes
          int [] primes = generatePrimes(maxValue);
          public static int [] generatePrimes(int maxValue)
         The test cases for the GeneratePrimes class are implemented using the JUnit testing framework. The tests are contained in class called TestGeneratePrames. There are a 5 tests for each return type (array and List), which appear to be similiar. Our first step to insure보증하다, 책임지다 that we are starting from a stable base is to make sure what we have works.
         Therefore, recompile the both GeneratePrimes and TestGeneratePrime and run the tests.
         Class TestsGeneratePrimes
         public class TestGeneratePrimes extends TestCase
          public TestGeneratePrimes(String name)
          int [] centArray = GeneratePrimes.generatePrimes(100);
          List centList = GeneratePrimes.primes(100);
          int [] primes = GeneratePrimes.getneratePrimes(bound);
          List primes = GeneratePrimes.primes(bound);
          int [] primes = GeneratePrimes.generatePrimes(m_primes[m_primes.length - 1]);
          List primes = GeneratePrimes.primes(m_primes[m_primes.length -1]);
          int [] primes = GeneratePrimes.generatePrimes(2);
          List primes = GeneratePrimes.primes(2);
          int [] primes = GeneratePrimes.generatePrimes(0);
          List primes = GeneratePrimes.primes(0);
Found 1 matching page out of 7544 total pages (5000 pages are searched)

You can also click here to search title.

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
Processing time 0.4378 sec