Tree Equality in Java


public static boolean
  equal(Object tree, Object other) {
    if ( consp(tree) )
        return ( consp(other) &&
                 equal(first((Cons) tree),
                       first((Cons) other)) &&
                 equal(rest((Cons) tree),
                       rest((Cons) other)) );
    return eql(tree, other); }

public static boolean      // leaf equality
  eql(Object tree, Object other) {
    return ( (tree == other) ||
             ( (tree != null) &&
               (other != null) &&
               tree.equals(other) ) ); }

Contents    Page-10    Prev    Next    Page+10    Index