RBLL { @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof RBLL)) return false; RBLL that = (RBLL) o; if (first == null && that.first == null) return true; if (first == null || that.first == null) return false; if (size() != that.size()) return false; LibBasedNode a = first, b = that.first; while (a != null) { assert b != null; if (!a.equals(b)) return false; a = a.next; b = b.next; } return true; }  @Override boolean equals(Object o); @Override int hashCode(); boolean containsInt(int elem); LibBasedNode getIntervalContaining(int elem); @Override String toString(); int size(); void clear(); void addInterval(int start, int end); static void main(String[] args);  }
@Test public void testEquals() throws Exception { RBLL rbll2 = new RBLL(); RBLL rbll3 = new RBLL(); rbll.addInterval(0, 6); rbll2.addInterval(0, 6); assertEquals(rbll, rbll2); assertThat(rbll, not(equalTo(rbll3))); rbll.addInterval(10, 16); rbll2.addInterval(10, 16); assertEquals(rbll, rbll2); assertThat(rbll, not(equalTo(rbll3))); rbll.addInterval(4, 16); rbll2.addInterval(4, 16); assertEquals(rbll, rbll2); assertThat(rbll, not(equalTo(rbll3))); }