blob: 087ceead472a218c41e74ed6566c977157584f72 (
plain) (
blame)
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
|
/*******************************************************************************
* Copyright (c) 2004, 2007 Boeing.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
package org.eclipse.osee.framework.jdk.core.collection.tree;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
public class TreeNode<treeType> {
private treeType myself;
private TreeNode<treeType> parent;
private List<TreeNode<treeType>> children;
protected TreeNode(TreeNode<treeType> parent, treeType myself) {
this.parent = parent;
this.myself = myself;
this.children = new ArrayList<TreeNode<treeType>>();
}
public TreeNode(treeType myself) {
this(null, myself);
}
public TreeNode() {
this(null);
}
public TreeNode<treeType> getParent() {
return parent;
}
public treeType getSelf() {
return myself;
}
public List<TreeNode<treeType>> getChildren() {
return children;
}
public TreeNode<treeType> addChild(treeType child) {
TreeNode<treeType> newchild = new TreeNode<treeType>(this, child);
this.children.add(newchild);
return newchild;
}
public void addChildren(Collection<treeType> children) {
for (treeType child : children) {
this.addChild(child);
}
}
}
|