package com.mjy.printer;

/**
 * 
 * @author MJ Lee
 *
 */
public final class BinaryTrees {

	private BinaryTrees() {
	}

	public static void print(BinaryTreeInfo tree) {
		print(tree, null);
	}

	public static void println(BinaryTreeInfo tree) {
		println(tree, null);
	}

	public static void print(BinaryTreeInfo tree, PrintStyle style) {
		if (tree == null || tree.root() == null) return;
		printer(tree, style).print();
	}

	public static void println(BinaryTreeInfo tree, PrintStyle style) {
		if (tree == null || tree.root() == null) return;
		printer(tree, style).println();
	}

	public static String printString(BinaryTreeInfo tree) {
		return printString(tree, null);
	}

	public static String printString(BinaryTreeInfo tree, PrintStyle style) {
		if (tree == null || tree.root() == null) return null;
		return printer(tree, style).printString();
	}

	private static Printer printer(BinaryTreeInfo tree, PrintStyle style) {
		if (style == PrintStyle.INORDER) return new InorderPrinter(tree);
		return new LevelOrderPrinter(tree);
	}

	public enum PrintStyle {
		LEVEL_ORDER, INORDER
	}
}
最近下载更多
Cathcode  LV1 2022年5月2日
wang512237140  LV20 2021年12月16日
matintalorr  LV10 2021年8月31日
xkfkb2341  LV1 2020年11月28日
xwq1234567  LV1 2020年10月27日
Cc1996  LV1 2020年10月26日
huangwu1026  LV1 2020年7月29日
2650343087  LV6 2020年5月26日
唐力刚  LV1 2020年5月13日
kyq123  LV1 2020年4月10日
最近浏览更多
wuziayng1232  LV10 2023年6月1日
我爱你野狼123 2023年3月22日
暂无贡献等级
666ing  LV2 2023年2月26日
heqian  LV16 2023年1月10日
微信网友_6248713511227392  LV11 2022年12月5日
vitos5n  LV9 2022年9月6日
crosa_Don  LV18 2022年7月6日
wang512237140  LV20 2021年12月16日
Luo qian98vu  LV1 2021年11月10日
tangjj7260  LV18 2021年10月25日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友