public RoomLeaf(int num) { parent = null; root = true; children = new List <RoomLeaf>(); this.num = num; }
void createTree() { roomLeaves = new RoomLeaf[17]; for (int i = 0; i < 17; i++) { roomLeaves[i] = new RoomLeaf(i + 1); } }
void addChildren(RoomLeaf child) { if (!child.root) { child.rotateTree(); } children.Add(child); child.parent = this; child.root = false; }
public void connect(RoomLeaf other) { if (other.getRoot().num < this.getRoot().num) { other.addChildren(this); } else if (other.getRoot().num > this.getRoot().num) { this.addChildren(other); } }
void rotateTree() { if (!parent.root) { parent.rotateTree(); } parent.children.Remove(this); parent.root = false; parent.parent = this; this.children.Add(parent); this.parent = null; this.root = true; }
public bool isConnectTo(RoomLeaf other) { return(this.getRoot().num == other.getRoot().num); }