Algorithm
Development Kit 1.0

algs.model.problems.convexhull
Class PartialHull

java.lang.Object
  extended by algs.model.problems.convexhull.PartialHull

public class PartialHull
extends java.lang.Object

Represents either the top or the bottom of a Convex Hull.

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

Constructor Summary
PartialHull(IPoint first, IPoint second)
          Construct the initial partial hull.
 
Method Summary
 void add(IPoint p)
          Add point to the Partial Hull.
 boolean areLastThreeNonRight()
          Determines if last three points reflect a right turn.
 IPoint[] getPoints()
          Return the points in this Partial Hull.
 boolean hasThree()
          Determine if there are more than 2 points currently in the partial hull.
 java.util.Iterator<IPoint> points()
          Return the points in this Partial Hull as an Iterator.
 boolean removeMiddleOfLastThree()
          Returns middle of last three.
 int size()
          Helper function to report number of points in the hull.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PartialHull

public PartialHull(IPoint first,
                   IPoint second)
Construct the initial partial hull.

Parameters:
first - Left-most point (for upper) and right-most (for lower)
second - Next one in sorted order, as the next assumed point in the hull.
Method Detail

add

public void add(IPoint p)
Add point to the Partial Hull.


removeMiddleOfLastThree

public boolean removeMiddleOfLastThree()
Returns middle of last three. Returns true on success; false otherwise.


hasThree

public boolean hasThree()
Determine if there are more than 2 points currently in the partial hull.


size

public int size()
Helper function to report number of points in the hull.


getPoints

public IPoint[] getPoints()
Return the points in this Partial Hull.


points

public java.util.Iterator<IPoint> points()
Return the points in this Partial Hull as an Iterator.


areLastThreeNonRight

public boolean areLastThreeNonRight()
Determines if last three points reflect a right turn. If hasThree() is false, then this returns false.


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.