Algorithm
Development Kit 1.0

algs.model.data.segments
Class IntegerGenerator

java.lang.Object
  extended by algs.model.data.Generator<ILineSegment>
      extended by algs.model.data.segments.IntegerGenerator

public class IntegerGenerator
extends Generator<ILineSegment>

Generators of sample lines using integer coordinated within the [max, max] box whose segment distance is length.

Make sure we don't generate single points as line segments.

Since:
1.0
Version:
1.0, 6/15/08
Author:
George Heineman

Constructor Summary
IntegerGenerator(int max, int length)
          Prepare generator with boundaries of the square together with the desired length of line segments to create.
 
Method Summary
 Generator<ILineSegment> construct(java.lang.String[] args)
          Provide reflective behavior to construct instance of generator given an array of string arguments.
 ILineSegment[] generate(int size)
          Generate a random set of segments within a [max,max] box, extending potentially out to a larger range based upon the length of each line segment.
 java.lang.String[] parameters()
          Declares the name of the parameters used when constructing the generator in order from left to right.
 
Methods inherited from class algs.model.data.Generator
toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IntegerGenerator

public IntegerGenerator(int max,
                        int length)
Prepare generator with boundaries of the square together with the desired length of line segments to create.

Parameters:
max - maximum square boundaries within which integers are generated
length - length of the line.
Method Detail

parameters

public java.lang.String[] parameters()
Description copied from class: Generator
Declares the name of the parameters used when constructing the generator in order from left to right.

Specified by:
parameters in class Generator<ILineSegment>

construct

public Generator<ILineSegment> construct(java.lang.String[] args)
Provide reflective behavior to construct instance of generator given an array of string arguments.

Specified by:
construct in class Generator<ILineSegment>

generate

public ILineSegment[] generate(int size)
Generate a random set of segments within a [max,max] box, extending potentially out to a larger range based upon the length of each line segment.

Each coordinate value of the segment is an integer.

Specified by:
generate in class Generator<ILineSegment>
Parameters:
size - The number of ILineSegments to create

Algorithm Development Kit 1.0

This code supports the Algorithms in a Nutshell book, published by O'Reilly Media, Inc. in November 2008. Please visit the book web page to learn of any changes to the code repository or to record a potential defect.