-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBiNode.java
47 lines (38 loc) · 1.01 KB
/
BiNode.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
* A bi-linkable node that extends Node adding a left reference.
* In fact, this implementation uses shadowing to simplify sone things..
*
* @author saulo
*
*/
public class BiNode extends Node {
private BiNode right, // shadows Node.right: points to right BiNode
left; // points to left BiNode
public BiNode() {
super();
}
public BiNode(CounterObject value) {
super(value);
}
/*
* Overrides Node.changeRight.
*
* A ClassCastException will be raised if other is a Node object!
*/
public void changeRight (Node other) throws ClassCastException {
this.right = (BiNode)other;
}
public void changeLeft (BiNode other) {
this.left = other;
}
/**
* Overrides Node.getRight()
* Thanks to the covariance rule!
*/
public Node getRight() {
return this.right;
}
public BiNode getLeft() {
return this.left;
}
} //==> class BiNode