Node: may be empty, having no data
* isEmpty()
This commit is contained in:
parent
921cf98b13
commit
36efe5d83a
2 changed files with 12 additions and 0 deletions
|
@ -20,6 +20,13 @@ public interface Node<T> {
|
||||||
*/
|
*/
|
||||||
T getData();
|
T getData();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the node is empty (has no data).
|
||||||
|
*
|
||||||
|
* @return true is data is null
|
||||||
|
*/
|
||||||
|
boolean isEmpty();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch the parent node.
|
* Fetch the parent node.
|
||||||
* <p>
|
* <p>
|
||||||
|
|
|
@ -50,6 +50,11 @@ public class NodeItem<T> implements Node<T> {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return data == null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Node<T> getParent() {
|
public Node<T> getParent() {
|
||||||
return parent;
|
return parent;
|
||||||
|
|
Loading…
Reference in a new issue