summaryrefslogtreecommitdiffstats
path: root/Algorithms
diff options
context:
space:
mode:
Diffstat (limited to 'Algorithms')
-rw-r--r--Algorithms/Part-I/3-Collinear/Fast.java10
1 files changed, 6 insertions, 4 deletions
diff --git a/Algorithms/Part-I/3-Collinear/Fast.java b/Algorithms/Part-I/3-Collinear/Fast.java
index 5d6ad48..6d9dcac 100644
--- a/Algorithms/Part-I/3-Collinear/Fast.java
+++ b/Algorithms/Part-I/3-Collinear/Fast.java
@@ -41,7 +41,8 @@ public class Fast
if (other == null) return false;
if (other.getClass() != this.getClass()) return false;
Segment s = (Segment) other;
- if ((pts[0].compareTo(s.pts[0]) == 0) || (pts[pts.length - 1].compareTo(s.pts[s.pts.length - 1]) == 0))
+ if ((pts[0].compareTo(s.pts[0]) == 0)
+ || (pts[pts.length - 1].compareTo(s.pts[s.pts.length - 1]) == 0))
return true;
return false;
}
@@ -69,8 +70,6 @@ public class Fast
Point ref = pts[i];
Point[] others = new Point[n];
- ref.draw();
-
for (int j = 0, k = i + 1; j < n; j++, k++)
others[j] = pts[k];
@@ -88,7 +87,8 @@ public class Fast
{
if ((start != -1) && ((j - start) > 2))
{
- Segment seg = new Segment(ref, others, start, (j - start + 1));
+ Segment seg = new Segment(ref, others,
+ start, (j - start + 1));
if (!segments.contains(seg))
segments.add(seg);
}
@@ -120,7 +120,9 @@ public class Fast
for (int i = 0; i < n; i++)
{
pts[i] = new Point(in.readInt(), in.readInt());
+ pts[i].draw();
}
+ Arrays.sort(pts);
// Stopwatch w = new Stopwatch();