MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / Point

Class Point

__tests__/fixtures/kernel-parity/TortureRecord.java:7–29  ·  view source on GitHub ↗

A 2-D point.

Source from the content-addressed store, hash-verified

5
6/** A 2-D point. */
7public record Point(int x, int y) implements Comparable<Point>, Shape {
8 public static final Point ORIGIN = new Point(0, 0);
9 private static int created;
10
11 public Point {
12 if (x < 0) throw new IllegalArgumentException("x");
13 created++;
14 }
15
16 public Point(int v) { this(v, v); }
17
18 /** Explicit accessor — no implicit one is minted. */
19 public int x() { return x; }
20
21 public double norm() { return Math.sqrt(x * x + y * y); }
22
23 @Override
24 public int compareTo(Point o) { return Double.compare(norm(), o.norm()); }
25
26 record Inner(String name, List<String> tags) {
27 String first() { return tags.get(0); }
28 }
29}
30
31record Pair<A, B>(A first, B second) {
32 A left() { return first; }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected