예제 #1
0
파일: App.java 프로젝트: cberes/convex-hull
 /** Returns the convex hull of points in the specified file using the specified algorithm */
 private static List<Point> findConvexHull(String path, Class<? extends ConvexHullAlg> alg)
     throws IOException {
   // read points from file
   List<Point> input = PointUtils.readFromFile(path);
   // find convex hull
   return ConvexHullAlg.create(input, alg).execute();
 }
예제 #2
0
파일: App.java 프로젝트: cberes/convex-hull
 /** Main entry point */
 public static void main(String[] args) throws IOException {
   try {
     // generate specified number of points at random
     // this means that no algorithms should have a numeric code in convexHullAlgs()
     Stream<Point> points =
         PointUtils.random(Integer.parseInt(args[0]), Integer.parseInt(args[1]));
     PointUtils.output((Iterable<Point>) points::iterator);
   } catch (NumberFormatException e) {
     // assume convex hull is to be found
     // look up the algorithm by the code
     final String code = args[1].toLowerCase(Locale.ENGLISH);
     Class<? extends ConvexHullAlg> alg = convexHullAlgs().get(code);
     if (alg != null) {
       PointUtils.output(findConvexHull(args[0], alg));
     } else {
       // not sure what user wants
       help();
     }
   }
 }