mirror of
https://github.com/corda/corda.git
synced 2025-06-18 15:18:16 +00:00
consolidate duplicate Cell classes
This commit is contained in:
@ -31,4 +31,24 @@ public class Cell <T> {
|
||||
sb.append(")");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static <Car> Cell<Car> cons(Car car, Cell<Car> cdr) {
|
||||
return new Cell(car, cdr);
|
||||
}
|
||||
|
||||
public static <T> boolean equal(T a, T b) {
|
||||
return (a == null && b == null) || (a != null && a.equals(b));
|
||||
}
|
||||
|
||||
public static <Car> boolean equal(Cell<Car> a, Cell<Car> b) {
|
||||
while (a != null) {
|
||||
if (b == null || (! equal(a.value, b.value))) {
|
||||
return false;
|
||||
}
|
||||
a = a.next;
|
||||
b = b.next;
|
||||
}
|
||||
|
||||
return b == null;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user