⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 node.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
字号:
package com.sun.electric.tool.generator.flag.hornFunnel2;

import java.util.List;

public class Node {
	private static int nodeCounter = 1;
	private final int id;
	private final int height; // Height in the tree.
	                          // height of leaf Node is 1
	private final Node leftChild, rightChild, parent;
	private int slot;
	public Node(Node parent, int height, int slot, List<Node> slots) {
		this.id = nodeCounter++;
		this.parent = parent;
		this.height = height;
		this.slot = slot;
		slots.set(slot, this);
		
		if (height==1) {
			leftChild = rightChild = null;
		} else {
			int childHeight = height-1;
			int childNbSlots = (int) (Math.pow(2, childHeight)-1);
			int halfChildSlots = (childNbSlots+1) /2;
			leftChild = new Node(this, childHeight, 
					             slot-halfChildSlots, slots);
			rightChild = new Node(this, childHeight, 
					              slot+halfChildSlots, slots);
		}
	}
	public Node getLeftChild() {return leftChild;}
	public Node getRightChild() {return rightChild;}
	public Node getParent() {return parent;}
	public int getSlot(){return slot;}
	public void setSlot(int s) {slot=s;}
	public int getHeight() {return height;}
	public boolean isLeaf() {return leftChild==null;}
	public boolean isRoot() {return parent==null;}
	public int getMinChildWireSlot() {
		int s = getSlot();
		if (isLeaf()) return s;
		s = Math.min(s, getLeftChild().getSlot());
		s = Math.min(s, getRightChild().getSlot());
		return s;
	}
	public int getMaxChildWireSlot() {
		int s = getSlot();
		if (isLeaf()) return s;
		s = Math.max(s, getLeftChild().getSlot());
		s = Math.max(s, getRightChild().getSlot());
		return s;
	}

	public int getChildWireLength() {
		return getMaxChildWireSlot() - getMinChildWireSlot();
	}
	public int getId() {return id;}
	@Override
	public String toString() {
		return "Node id="+id+" height="+height+" slot="+slot+
		       " childWireLen="+getChildWireLength();
	}
	public static void resetIds() {nodeCounter=1;}
}

⌨️ 快捷键说明

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