@Test public void test3() { Position p1 = new Position(0, 1); Position p2 = new Position(0, 0); assertTrue(p1.compareTo(p2) > 0); }
@Override public int compareTo(Position p) { if (p == null) { return Integer.MIN_VALUE; } if (m_line < p.m_line) { return -1; } if (m_line > p.m_line) { return 1; } return m_column - p.m_column; }
Position implements Comparable<Position> { @Override public int compareTo(Position p) { if (p == null) { return Integer.MIN_VALUE; } if (m_line < p.m_line) { return -1; } if (m_line > p.m_line) { return 1; } return m_column - p.m_column; } }
Position implements Comparable<Position> { @Override public int compareTo(Position p) { if (p == null) { return Integer.MIN_VALUE; } if (m_line < p.m_line) { return -1; } if (m_line > p.m_line) { return 1; } return m_column - p.m_column; } Position(int line, int column); }
Position implements Comparable<Position> { @Override public int compareTo(Position p) { if (p == null) { return Integer.MIN_VALUE; } if (m_line < p.m_line) { return -1; } if (m_line > p.m_line) { return 1; } return m_column - p.m_column; } Position(int line, int column); int getLine(); int getColumn(); @Override String toString(); @Override int compareTo(Position p); @Override int hashCode(); @Override boolean equals(Object o); Position moveBy(int offset); }
Position implements Comparable<Position> { @Override public int compareTo(Position p) { if (p == null) { return Integer.MIN_VALUE; } if (m_line < p.m_line) { return -1; } if (m_line > p.m_line) { return 1; } return m_column - p.m_column; } Position(int line, int column); int getLine(); int getColumn(); @Override String toString(); @Override int compareTo(Position p); @Override int hashCode(); @Override boolean equals(Object o); Position moveBy(int offset); static final Position ZERO; static final Nowhere NOWHERE; }