0N/A/*
1472N/A * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
0N/Apackage sun.jvm.hotspot.utilities;
0N/A
0N/A/** This class implements a node in a red-black tree. It provides
0N/A accessors for the left and right children as well as the color of
0N/A the node. */
0N/A
0N/Apublic class RBNode {
0N/A private Object data;
0N/A private RBNode left;
0N/A private RBNode right;
0N/A private RBNode parent;
0N/A private RBColor color;
0N/A
0N/A /** Newly-created nodes are colored red */
0N/A public RBNode(Object data) {
0N/A this.data = data;
0N/A color = RBColor.RED;
0N/A }
0N/A
0N/A public Object getData() {
0N/A return data;
0N/A }
0N/A
0N/A /** Must copy all user-defined fields from the given node. For
0N/A example, the base implementation copies the "data" field.
0N/A However, it does not (and must not) copy the link fields
0N/A (parent, left child, right child). It also does not need to copy
0N/A any computed information for the node, as the node will be
0N/A updated when necessary. Subclasses must be careful to call the
0N/A superclass implementation. */
0N/A public void copyFrom(RBNode arg) {
0N/A this.data = arg.data;
0N/A }
0N/A
0N/A /** This is called by the base RBTree's insertion and deletion
0N/A methods when necessary. Subclasses can use this to update any
0N/A computed information based on the information in their left or
0N/A right children. For multi-node updates it is guaranteed that
0N/A this method will be called in the correct order. This should
0N/A return true if an update actually occurred, false if not. */
0N/A public boolean update() {
0N/A return false;
0N/A }
0N/A
0N/A public RBColor getColor() { return color; }
0N/A public void setColor(RBColor color) { this.color = color; }
0N/A
0N/A public RBNode getParent() { return parent; }
0N/A public void setParent(RBNode parent) { this.parent = parent; }
0N/A
0N/A /** Access to left child */
0N/A public RBNode getLeft() { return left; }
0N/A public void setLeft(RBNode left) { this.left = left; }
0N/A
0N/A /** Access to right child */
0N/A public RBNode getRight() { return right; }
0N/A public void setRight(RBNode right) { this.right = right; }
0N/A}