Path: blob/master/test/hotspot/jtreg/vmTestbase/jit/graph/Node.java
40948 views
/*1* Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223package jit.graph;2425// This class define the tree node.2627public class Node {28public final static int Black = 0; // constants used to define the29public final static int Red = 1; // node color30public final static int Left_son = 2; // constants used to identify31public final static int Right_son = 3;// the node parent and sons.32public final static int Parent = 4;3334private int color;35private int key;36private Node L, R, P; // L-left son,R-right son,P-parent3738// constructor create a new node the default color is red39// the default appearance (bold) is regular.40// initialize the key field.4142public Node(int k) {43color = Red;44key = k;45L = null;46R = null;47P = null;48}4950// constructor for constructing a tree null object, is color51// is black.5253public Node() {54color = Black;55key = -1;56L = null;57R = null;58P = null;59}6061// This method set the node key.6263public void setKey(int k) {64key = k;65}6667// This method return the node key.6869public int getKey() {70return (key);71}7273// This method set the node color.7475public void setColor(int c) {76if (c == Black) {77color = Black;78} else if (c == Red) {79color = Red;80}81}8283// This method return the node color.8485public int getColor() {86return (color);87}8889// This method set the node parent or childs acording to the who90// parameter.9192public void setNode(int who, Node n) {93switch (who) {94case Left_son:95L = n;96break;97case Right_son:98R = n;99break;100case Parent:101P = n;102break;103}104}105106// This method return the node parent or childs acording to the who107// parameter.108109public Node getNode(int who) {110switch (who) {111case Left_son:112return L;113case Right_son:114return R;115case Parent:116return P;117}118return null;119}120}121122123