@Test public void testLongRedBlackTree() { LongRedBlackTree rbt = new LongRedBlackTree(); System.out.println("Test put method"); rbt.put(25, new Long(25)); rbt.put(234, new Long(234)); rbt.put(2,new Long(2) ); rbt.put(999, new Long(999)); rbt.put(0, new Long(0)); rbt.put(700, new Long(700)); test(rbt, 25, new Long(25)); test(rbt,234, new Long(234)); test(rbt,2,new Long(2) ); test(rbt,999, new Long(999)); test(rbt,0, new Long(0)); test(rbt,700, new Long(700)); System.out.println("Test atOrBefore and atOrAfter methods"); Object obj = rbt.getAtOrBefore(600); if (!obj.equals(new Long(234))) { Assert.fail("Value at or before 600 should be 234, but was "+rbt.getAtOrBefore(600)); } obj = rbt.getAtOrAfter(600); if (!obj.equals(new Long(700))) { Assert.fail("Value at or after 600 should be 700, but was "+rbt.getAtOrBefore(600)); } obj = rbt.getAtOrBefore(700); if (!obj.equals(new Long(700))) { Assert.fail("Value at or before 700 should be 700, but was "+rbt.getAtOrBefore(600)); } obj = rbt.getAtOrBefore(10000); if (!obj.equals(new Long(999))) { Assert.fail("Value at or before 10000 should be 999, but was "+rbt.getAtOrBefore(600)); } System.out.println("Test the iterator"); Iterator<?> it = rbt.iterator(); Object[] objs = new Object[6]; objs[0] = new Long(0); objs[1] = new Long(2); objs[2] = new Long(25); objs[3] = new Long(234); objs[4] = new Long(700); objs[5] = new Long(999); int i = 0; while(it.hasNext()) { Object o = it.next(); if (!o.equals(objs[i])) { Assert.fail("expected "+objs[i]+" but got "+o); } i++; } }
public LongRedBlackTree() { }
LongRedBlackTree implements Serializable { public LongRedBlackTree() { } }
LongRedBlackTree implements Serializable { public LongRedBlackTree() { } LongRedBlackTree(); }
LongRedBlackTree implements Serializable { public LongRedBlackTree() { } LongRedBlackTree(); int size(); boolean containsKey(long key); Object get(long key); Object getAtOrAfter(long key); Object getAtOrBefore(long key); long getFirst(); long getLast(); long getNext(long key); long getPrevious(long key); void put(long key, Object obj); Object remove(long key); void removeAll(); boolean isEmpty(); Iterator<?> iterator(); }
LongRedBlackTree implements Serializable { public LongRedBlackTree() { } LongRedBlackTree(); int size(); boolean containsKey(long key); Object get(long key); Object getAtOrAfter(long key); Object getAtOrBefore(long key); long getFirst(); long getLast(); long getNext(long key); long getPrevious(long key); void put(long key, Object obj); Object remove(long key); void removeAll(); boolean isEmpty(); Iterator<?> iterator();  }