public override int GetHashCode() { unchecked { return(Node1.GetHashCode() ^ Node2.GetHashCode() ^ Node3.GetHashCode() ^ Node4.GetHashCode()); } }
public CorridorNode(Node3 node1, Node3 node2, int corridorWidth) : base(null) { this.structure1 = node1; this.structure2 = node2; this.corridorWidth = corridorWidth; GenerateCorridor(); }
public override string ToString() { return("[ " + Node1.ToString() + "\t" + Node2.ToString() + "\t" + Node3.ToString() + "\t" + Node4.ToString() + " ]"); }
public void DeleteFromXml(string PageName, int PageId, int UserId) { try { int PId = PageId; int UId = UserId; XmlDocument xmldoc = new XmlDocument(); xmldoc.Load(Session["HomePath"].ToString() + BannerOrder.BannerXml); XmlNodeList Node1; Node1 = xmldoc.GetElementsByTagName("banner"); int Totalcnt = Node1.Count; for (int i = 0; i < Node1.Count; i++) { XmlElement id = (XmlElement)xmldoc.GetElementsByTagName("banner")[i]; if (id.ChildNodes.Item(4).InnerText.ToString() == PageName) { id.ParentNode.RemoveChild(id); i = i - 1; } } int tempNodeId = 0; tempNodeId = GetPagesNode(PId, UId); XmlNodeList Node2; Node2 = xmldoc.GetElementsByTagName("banners"); int c = Node2.Item(tempNodeId).ChildNodes.Count; XmlNodeList Node3; Node3 = xmldoc.GetElementsByTagName("bannerName"); Node3.Item(tempNodeId).FirstChild.InnerText = Node2.Item(tempNodeId).ChildNodes.Count.ToString(); xmldoc.Save(ContentManager.GetPhysicalPath(Session["HomePath"].ToString() + "banners_Cat1.xml")); } catch (Exception Ex) { ErrMessage(Ex.Message.ToString()); } }
public static List <Node3> TraverseGraphToExtractLowestLeafes(Node3 parentNode) { Queue <Node3> nodesToCheck = new Queue <Node3>(); List <Node3> listToReturn = new List <Node3>(); if (parentNode.ChildrenNodeList.Count == 0) { return(new List <Node3>() { parentNode }); } foreach (var child in parentNode.ChildrenNodeList) { nodesToCheck.Enqueue(child); } while (nodesToCheck.Count > 0) { var currentNode = nodesToCheck.Dequeue(); if (currentNode.ChildrenNodeList.Count == 0) { listToReturn.Add(currentNode); } else { foreach (var child in currentNode.ChildrenNodeList) { nodesToCheck.Enqueue(child); } } } return(listToReturn); }
//把新的节点插入到最前面 public void push(int new_data) { Node3 new_node = new Node3(new_data); new_node.next = head3; head3 = new_node; }
public void deleteNode(int position) { //链表是否为空 //即头部是否为Null if (head3 == null) { return; } //如果要删除头部节点 Node3 temp = head3; if (position == 0) { //把头部节点的下一个节点赋值给头部节点 head3 = temp.next; return; } if (temp != null) //存在头部节点 { //遍历当前位置前面的所有节点 } //考虑头部节点为null }
public void Init(NormPoint p1, NormPoint p2) { BeginCoord = p1; EndCoord = p2; Node3.UpdateCoord(BeginCoord.X, EndCoord.Y); Node4.UpdateCoord(EndCoord.X, BeginCoord.Y); }
public void DeleteFromXml(string str) { XmlDocument xmldoc = new XmlDocument(); xmldoc.Load(Session["HomePath"].ToString() + "banners_Cat.xml"); XmlNodeList Node1; Node1 = xmldoc.GetElementsByTagName("banner"); for (int i = 0; i < Node1.Count; i++) { XmlElement id = (XmlElement)xmldoc.GetElementsByTagName("banner")[i]; if (id.ChildNodes.Item(2).InnerText.ToString() == str) { id.ParentNode.RemoveChild(id); } } XmlNodeList Node2; Node2 = xmldoc.GetElementsByTagName("banners"); int c = Node2.Item(Convert.ToInt32(ddlUserType.SelectedValue)).ChildNodes.Count; XmlNodeList Node3; Node3 = xmldoc.GetElementsByTagName("bannerName"); Node3.Item(Convert.ToInt32(ddlUserType.SelectedValue)).FirstChild.InnerText = Node2.Item(Convert.ToInt32(ddlUserType.SelectedValue)).ChildNodes.Count.ToString(); xmldoc.Save(ContentManager.GetPhysicalPath(Session["HomePath"].ToString() + "banners_Cat.xml")); }
public RoomNode(Vector2Int bottomLeftAreaCorner, Vector2Int topRightAreaCorner, Node3 parentNode, int index) : base(parentNode) { this.BottomLeftAreaCorner = bottomLeftAreaCorner; this.TopRightAreaCorner = topRightAreaCorner; this.BottomRightAreaCorner = new Vector2Int(topRightAreaCorner.x, bottomLeftAreaCorner.y); this.TopLeftAreaCorner = new Vector2Int(bottomLeftAreaCorner.x, TopRightAreaCorner.y); this.TreeLayerIndex = index; }
private Node3(Node3 other, short direction, ushort toMove) { NumSteps = other.NumSteps + 1; _elevatorFloor = (ushort)(other._elevatorFloor + direction); _floors = new ushort[4]; other._floors.CopyTo(_floors, 0); Move(toMove, other._elevatorFloor, other._elevatorFloor + direction); }
static void Main(string[] args) { try { //выделяется на стеке //кидает StackoverflowException //если закоментировать, то падать перестанет if (true) { Node3 n1; Node3 n2; Node3 n3; Node3 n4; Node3 n5; Node3 n6; Node3 n7; Node3 n8; Node3 n9; Node3 n11; Node3 n12; Node3 n13; Node3 n14; Node3 n15; Node3 n16; Node3 n17; Node3 n18; Node3 n19; Node3 n21; Node3 n22; Node3 n23; Node3 n24; Node3 n25; Node3 n26; Node3 n27; Node3 n28; Node3 n29; Node3 n31; Node3 n32; Node3 n33; Node3 n34; Node3 n35; Node3 n36; Node3 n37; Node3 n38; Node3 n39; } //выделяется на heap-е var nodes = new Node3[100]; nodes[2] = nodes[0].Add(ref nodes[1]); } catch (Exception exc) { Console.Error.WriteLine(exc); } }
public void Init(NormPoint p1, NormPoint p2, System.Drawing.Color Color, float Thick = 1) { BeginCoord = p1; EndCoord = p2; Node3.UpdateCoord(BeginCoord.X, EndCoord.Y); Node4.UpdateCoord(EndCoord.X, BeginCoord.Y); SelectBorderColor(Color.R, Color.G, Color.B, Color.A); SelectLineThick(Thick); }
private void ProcessRoomInRelationUpOrDown(Node3 structure1, Node3 structure2) { Node3 bottomStructure = null; List <Node3> structureBottmChildren = StructureHelper.TraverseGraphToExtractLowestLeafes(structure1); Node3 topStructure = null; List <Node3> structureAboveChildren = StructureHelper.TraverseGraphToExtractLowestLeafes(structure2); var sortedBottomStructure = structureBottmChildren.OrderByDescending(child => child.TopRightAreaCorner.y).ToList(); if (sortedBottomStructure.Count == 1) { bottomStructure = structureBottmChildren[0]; } else { int maxY = sortedBottomStructure[0].TopLeftAreaCorner.y; sortedBottomStructure = sortedBottomStructure.Where(child => Mathf.Abs(maxY - child.TopLeftAreaCorner.y) < 10).ToList(); int index = UnityEngine.Random.Range(0, sortedBottomStructure.Count); bottomStructure = sortedBottomStructure[index]; } var possibleNeighboursInTopStructure = structureAboveChildren.Where( child => GetValidXForNeighbourUpDown( bottomStructure.TopLeftAreaCorner, bottomStructure.TopRightAreaCorner, child.BottomLeftAreaCorner, child.BottomRightAreaCorner) != -1).OrderBy(child => child.BottomRightAreaCorner.y).ToList(); if (possibleNeighboursInTopStructure.Count == 0) { topStructure = structure2; } else { topStructure = possibleNeighboursInTopStructure[0]; } int x = GetValidXForNeighbourUpDown( bottomStructure.TopLeftAreaCorner, bottomStructure.TopRightAreaCorner, topStructure.BottomLeftAreaCorner, topStructure.BottomRightAreaCorner); while (x == -1 && sortedBottomStructure.Count > 1) { sortedBottomStructure = sortedBottomStructure.Where(child => child.TopLeftAreaCorner.x != topStructure.TopLeftAreaCorner.x).ToList(); bottomStructure = sortedBottomStructure[0]; x = GetValidXForNeighbourUpDown( bottomStructure.TopLeftAreaCorner, bottomStructure.TopRightAreaCorner, topStructure.BottomLeftAreaCorner, topStructure.BottomRightAreaCorner); } BottomLeftAreaCorner = new Vector2Int(x, bottomStructure.TopLeftAreaCorner.y); TopRightAreaCorner = new Vector2Int(x + this.corridorWidth, topStructure.BottomLeftAreaCorner.y); }
private void ProcessRoomInRelationRightOrLeft(Node3 structure1, Node3 structure2) { Node3 leftStructure = null; List <Node3> leftStructureChildren = StructureHelper.TraverseGraphToExtractLowestLeafes(structure1); Node3 rightStructure = null; List <Node3> rightStructureChildren = StructureHelper.TraverseGraphToExtractLowestLeafes(structure2); var sortedLeftStructure = leftStructureChildren.OrderByDescending(child => child.TopRightAreaCorner.x).ToList(); if (sortedLeftStructure.Count == 1) { leftStructure = sortedLeftStructure[0]; } else { int maxX = sortedLeftStructure[0].TopRightAreaCorner.x; sortedLeftStructure = sortedLeftStructure.Where(children => Math.Abs(maxX - children.TopRightAreaCorner.x) < 10).ToList(); int index = UnityEngine.Random.Range(0, sortedLeftStructure.Count); leftStructure = sortedLeftStructure[index]; } var possibleNeighboursInRightStructureList = rightStructureChildren.Where( child => GetValidYForNeighourLeftRight( leftStructure.TopRightAreaCorner, leftStructure.BottomRightAreaCorner, child.TopLeftAreaCorner, child.BottomLeftAreaCorner ) != -1 ).ToList(); if (possibleNeighboursInRightStructureList.Count <= 0) { rightStructure = structure2; } else { rightStructure = possibleNeighboursInRightStructureList[0]; } int y = GetValidYForNeighourLeftRight(leftStructure.TopLeftAreaCorner, leftStructure.BottomRightAreaCorner, rightStructure.TopLeftAreaCorner, rightStructure.BottomLeftAreaCorner); while (y == -1 && sortedLeftStructure.Count > 1) { sortedLeftStructure = sortedLeftStructure.Where( child => child.TopLeftAreaCorner.y != leftStructure.TopLeftAreaCorner.y).ToList(); leftStructure = sortedLeftStructure[0]; y = GetValidYForNeighourLeftRight(leftStructure.TopLeftAreaCorner, leftStructure.BottomRightAreaCorner, rightStructure.TopLeftAreaCorner, rightStructure.BottomLeftAreaCorner); } BottomLeftAreaCorner = new Vector2Int(leftStructure.BottomRightAreaCorner.x, y); TopRightAreaCorner = new Vector2Int(rightStructure.TopLeftAreaCorner.x, y + this.corridorWidth); }
private void btn_elmt_add_Click(object sender, EventArgs e) { string kStr = ""; if (DGV != null) { if (btn_elmt_add.Text == "Change") { if (ASTRA_Data.Count > 0) { kStr = ASTRA_Data[0]; } int r = MyStrings.StringToInt(kStr, 0); DGV[0, r].Value = ElementNo; DGV[1, r].Value = Node1.ToString(); DGV[2, r].Value = Node2.ToString(); DGV[3, r].Value = Node3.ToString(); DGV[4, r].Value = Node4.ToString(); Draw_Elements(); this.Close(); } else if (btn_elmt_add.Text == "Insert") { int r = DGV.CurrentCell.RowIndex; if (DGV.SelectedCells.Count > 0) { r = DGV.SelectedCells[0].RowIndex; } DGV.Rows.Insert(r, ElementNo, Node1, Node2, Node3, Node4); ElementNo = ElementNo + 1; Draw_Elements(); } else { DGV.Rows.Add(ElementNo, Node1, Node2, Node3, Node4); ElementNo = ElementNo + 1; Draw_Elements(); } } else { this.Close(); } }
private Node3(Node3 other, short direction, ushort toMove1, ushort toMove2) : this(other, direction, toMove1) { Move(toMove2, other._elevatorFloor, other._elevatorFloor + direction); }
public Node3(int d) { data = d; next = null; }
public IEnumerable <Node3> CreateChildren() { ushort i = 0; var floor = _floors[_elevatorFloor]; while (floor > i) { if (i == 0) { i = 1; } else { i <<= 1; } if ((floor & i) == 0) { continue; } // Elevetor going up Node3 child; if (_elevatorFloor < 3) { child = new Node3(this, 1, i); if (child.IsValid(_elevatorFloor, _elevatorFloor + 1)) { yield return(child); } ushort j = i; while (floor > j) { j <<= 1; if ((floor & j) == 0) { continue; } child = new Node3(this, 1, i, j); if (child.IsValid(_elevatorFloor, _elevatorFloor + 1)) { yield return(child); } } } // Going down if (_elevatorFloor >= 1) { child = new Node3(this, -1, i); if (child.IsValid(_elevatorFloor, _elevatorFloor - 1)) { yield return(child); } ushort j = i; while (floor > j) { j <<= 1; if ((floor & j) == 0) { continue; } child = new Node3(this, -1, i, j); if (child.IsValid(_elevatorFloor, _elevatorFloor - 1)) { yield return(child); } } } } }
public Node3 <T, M> Node3(Node3 <T, M> other) { return(new Node3 <T, M>(_m, other)); }