twothreepnodeuos.java

来自「国外的数据结构与算法分析用书」· Java 代码 · 共 62 行

JAVA
62
字号
/* TwoThreePNodeUos.java
 * ---------------------------------------------
 * Copyright (c) 2001 University of Saskatchewan
 * All Rights Reserved
 * --------------------------------------------- */

package dslib.dictionary.twothreetree;

import dslib.base.PairUos;
import java.io.Serializable;

/**	A node for a two-three tree.  It has a key instance variable,
	the methods search, insert, and delete, and a formatted output. */
public abstract class TwoThreePNodeUos implements Cloneable, Serializable
{
	/**	The parent node of this node. */
	protected TwoThreePInteriorUos parent;

	/**	The parent node of this node. <br> 
		Analysis: Time = O(1) */
	public TwoThreePInteriorUos parent()
	{
		return parent;
	}

	/**	Set the parent equal to y. <br> 
		Analysis: Time = O(1) 
		@param y The new parent */
	public void setParent(TwoThreePInteriorUos y)
	{
		parent = y;
	}

	/**	Search for the item with key i. */
	public abstract void search(Comparable i, TwoThreePKeyedDictUos treeHeader);

	/**	Should insert object y with key i and returns the extra node. */
	public abstract PairUos insert(Comparable i, Object y);

	/**	Delete the item with key i. */
	public abstract boolean delete(Comparable i);

	/**	String representation of the contents of the node with indentation
		for different levels of the tree. */
	public abstract String formatToString(String indentation);

	/**	A shallow clone of this object. <br> 
		Analysis: Time = O(1) */
	public Object clone()
	{
		try
		{
			return super.clone();
		} catch (CloneNotSupportedException e)
		{
			/*	Should not occur: implements Cloneable. */ 
			e.printStackTrace();
			return null;
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?