All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.tinygroup.binarytree.BinaryTree Maven / Gradle / Ivy

There is a newer version: 2.2.3
Show newest version
/**
 *  Copyright (c) 1997-2013, www.tinygroup.org ([email protected]).
 *
 *  Licensed under the GPL, Version 3.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *       http://www.gnu.org/licenses/gpl.html
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package org.tinygroup.binarytree;

import org.tinygroup.binarytree.impl.BinaryTreeImpl;
import org.tinygroup.commons.processor.Processor;

/**
 * Created by IntelliJ IDEA.
* User: luoguo
* Date: 11-3-31 Time: 上午11:10
* To change this template use File | Settings | File Templates. */ public interface BinaryTree> { int DLR_ORDER = -1;// 前序 int LDR_ORDER = 0;// 中序 int LRD_ORDER = 1;// 后序 BinaryTree search(T find); /** * 增加一个节点 * * @param t */ BinaryTree add(T t); /** * 返回当前节点数据 * * @return */ T getData(); /** * 删除指定结点子树 * * @param t */ void remove(T t); /** * 对每个节点执行操作 * * @param process */ void foreach(Processor process); /** * 用指定的遍历方式对每一个节点执行操作 * * @param process * @param mode * 前序、后序、中序 */ void foreach(Processor process, int mode); BinaryTreeImpl getParent(); /** * 求树的节点数 * * @return */ int size(); /** * 获取树的高度 * * @return */ int height(); /** * 转换为平衡二叉树 * * @return */ AVLTree toAVLTree(); }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy