Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/jit/graph/Node.java
40948 views
1
/*
2
* Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
package jit.graph;
25
26
// This class define the tree node.
27
28
public class Node {
29
public final static int Black = 0; // constants used to define the
30
public final static int Red = 1; // node color
31
public final static int Left_son = 2; // constants used to identify
32
public final static int Right_son = 3;// the node parent and sons.
33
public final static int Parent = 4;
34
35
private int color;
36
private int key;
37
private Node L, R, P; // L-left son,R-right son,P-parent
38
39
// constructor create a new node the default color is red
40
// the default appearance (bold) is regular.
41
// initialize the key field.
42
43
public Node(int k) {
44
color = Red;
45
key = k;
46
L = null;
47
R = null;
48
P = null;
49
}
50
51
// constructor for constructing a tree null object, is color
52
// is black.
53
54
public Node() {
55
color = Black;
56
key = -1;
57
L = null;
58
R = null;
59
P = null;
60
}
61
62
// This method set the node key.
63
64
public void setKey(int k) {
65
key = k;
66
}
67
68
// This method return the node key.
69
70
public int getKey() {
71
return (key);
72
}
73
74
// This method set the node color.
75
76
public void setColor(int c) {
77
if (c == Black) {
78
color = Black;
79
} else if (c == Red) {
80
color = Red;
81
}
82
}
83
84
// This method return the node color.
85
86
public int getColor() {
87
return (color);
88
}
89
90
// This method set the node parent or childs acording to the who
91
// parameter.
92
93
public void setNode(int who, Node n) {
94
switch (who) {
95
case Left_son:
96
L = n;
97
break;
98
case Right_son:
99
R = n;
100
break;
101
case Parent:
102
P = n;
103
break;
104
}
105
}
106
107
// This method return the node parent or childs acording to the who
108
// parameter.
109
110
public Node getNode(int who) {
111
switch (who) {
112
case Left_son:
113
return L;
114
case Right_son:
115
return R;
116
case Parent:
117
return P;
118
}
119
return null;
120
}
121
}
122
123