-
Notifications
You must be signed in to change notification settings - Fork 19.4k
/
LargeTreeNode.java
77 lines (67 loc) · 2.08 KB
/
LargeTreeNode.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package com.thealgorithms.devutils.nodes;
import java.util.Collection;
/**
* {@link TreeNode} extension that holds a {@link Collection} of refrences to
* child Nodes.
*
* @param <E> The type of the data held in the Node.
*
* @author <a href="https://github.com/aitorfi">aitorfi</a>
*/
public class LargeTreeNode<E> extends TreeNode<E> {
/**
* {@link Collection} that holds the Nodes' child nodes.
*/
private Collection<LargeTreeNode<E>> childNodes;
/**
* Empty contructor.
*/
public LargeTreeNode() {
super();
}
/**
* Initializes the Nodes' data.
*
* @param data Value to which data will be initialized.
* @see TreeNode#TreeNode(Object)
*/
public LargeTreeNode(E data) {
super(data);
}
/**
* Initializes the Nodes' data and parent node reference.
*
* @param data Value to which data will be initialized.
* @param parentNode Value to which the nodes' parent reference will be set.
* @see TreeNode#TreeNode(Object, Node)
*/
public LargeTreeNode(E data, LargeTreeNode<E> parentNode) {
super(data, parentNode);
}
/**
* Initializes the Nodes' data and parent and child nodes references.
*
* @param data Value to which data will be initialized.
* @param parentNode Value to which the nodes' parent reference will be set.
* @param childNodes {@link Collection} of child Nodes.
* @see TreeNode#TreeNode(Object, Node)
*/
public LargeTreeNode(E data, LargeTreeNode<E> parentNode, Collection<LargeTreeNode<E>> childNodes) {
super(data, parentNode);
this.childNodes = childNodes;
}
/**
* @return True if the node is a leaf node, otherwise false.
* @see TreeNode#isLeafNode()
*/
@Override
public boolean isLeafNode() {
return (childNodes == null || childNodes.isEmpty());
}
public Collection<LargeTreeNode<E>> getChildNodes() {
return childNodes;
}
public void setChildNodes(Collection<LargeTreeNode<E>> childNodes) {
this.childNodes = childNodes;
}
}