Skip to content

Commit

Permalink
Revert "按照多重字段排序 (#97)"
Browse files Browse the repository at this point in the history
This reverts commit d33309e.
  • Loading branch information
hcsp-bot committed Jan 9, 2020
1 parent d33309e commit a98ac26
Showing 1 changed file with 2 additions and 22 deletions.
24 changes: 2 additions & 22 deletions src/main/java/com/github/hcsp/polymorphism/Point.java
Expand Up @@ -2,14 +2,12 @@

import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class Point implements Comparable<Point> {
public class Point {

private final int x;
private final int y;

// 代表笛卡尔坐标系中的一个点
public Point(int x, int y) {
this.x = x;
Expand Down Expand Up @@ -55,10 +53,7 @@ public String toString() {

// 按照先x再y,从小到大的顺序排序
// 例如排序后的结果应该是 (-1, 1) (1, -1) (2, -1) (2, 0) (2, 1)
public static List<Point> sort(List<Point> points) {
Collections.sort(points);
return points;
}
public static List<Point> sort(List<Point> points) {}

public static void main(String[] args) throws IOException {
List<Point> points =
Expand All @@ -70,19 +65,4 @@ public static void main(String[] args) throws IOException {
new Point(2, -1));
System.out.println(Point.sort(points));
}

@Override
public int compareTo(Point that) {
if (this.x > that.x) {
return 1;
} else if (this.x < that.x) {
return -1;
}
if (this.y < that.y) {
return -1;
} else if (this.y > that.y) {
return 1;
}
return 0;
}
}

0 comments on commit a98ac26

Please sign in to comment.