/* RBNode.java

	Purpose:
		
	Description:
		
	History:
		Oct 22, 2014 5:50:58 PM, Created by henrichen

	Copyright (C) 2014 Potix Corporation. All Rights Reserved.
*/
package org.zkoss.zssex.util;

import java.io.Serializable;

/**
 * @author henri
 *
 */
/**
 * A Red-Black tree node in {@link RBTree}.
 *
 * @author henrichen
 *
 */
class RBNode<K, V> implements Serializable {
	private static final long serialVersionUID = 3149703939824128755L;

	/// key of this tree node.
	private K key;
	  
	/// value(payload) of this tree node.
	private V value;
	  
	/// whether this is a red node; default to red.
	private boolean color = RBTree._RED;
	  
	/// left child of this node.
	private RBNode<K, V> left;
	  
	/// right child of this node.
	private RBNode<K, V> right;

	/// Constructor
	RBNode(K key, V value) {
		this.key = key;
		this.value = value;
	}
	  
	public boolean getColor() {
		return color;
	}
	
	public void setColor(boolean color) {
		this.color = color;
	}
	
	public K getKey() {
		return key;
	}

	public void setKey(K key) {
		this.key = key;
	}

	public V getValue() {
		return value;
	}

	public void setValue(V value) {
		this.value = value;
	}

	public RBNode<K, V> getLeft() {
		return left;
	}

	public void setLeft(RBNode<K, V> left) {
		this.left = left;
	}

	public RBNode<K, V> getRight() {
		return right;
	}

	public void setRight(RBNode<K, V> right) {
		this.right = right;
	}

	@Override
	public String toString() {
		return ""+ getClass().getName() + "(" + key + ")";
	}
}

