/** * Initializes all traversal stacks. */ public IntersectionState() { stack = new StackNode[MAX_STACK_SIZE * 2]; for (int i = 0; i < stack.Length; i++) stack[i] = new StackNode(); rstack = new float[53 * 256]; }
public void pop() { if (!isEmpty()) top = top.link; else throw new Exception("Pop Attemped on an empty stack"); }
/** * Initializes all traversal stacks. */ public IntersectionState() { for (int i = 0; i < stacks.Length; i++) { stacks[i] = new StackNode[MAX_STACK_SIZE]; for (int j = 0; j < stacks[i].Length; j++) stacks[i][j] = new StackNode(); } }
internal void Push(char ch) { StackNode data = new StackNode(); data.root = _root; data.top = _top; data.charPushed = ch; _nodeStack.Push(data); _root = new ExprNode(null); _top = _root; _isStart = true; }
public void ValidateSupportedElements() { StackNode stack = CreateFilteredStackNode(k_DefaultX, k_DefaultY); stack.AddElement(CreateStackNode(10, 10)); stack.AddElement(CreateScope(10, 10)); stack.AddElement(CreateGroup("", 10, 10)); stack.AddElement(new UnsupportedNode()); // Verify that none of the above attempts succeeded Assert.AreEqual(0, stack.childCount); stack.AddElement(m_Node1); //Verify that a regular element is accepted Assert.AreEqual(1, stack.childCount); }
public void Push(T item) { StackNode <T> q = new StackNode <T>(item); if (top == null) { top = q; } else { q.Next = top; top = q; } ++size; }
public void Pop() { if (IsEmpty()) { Console.WriteLine("Стек пуст"); } else { StackNode node = top; top = top.next; node.next = null; node = null; count--; } }
public void Push(int data) { StackNode node = new StackNode(data); if (IsEmpty()) { node.Min = data; } else { node.Min = (Top.Min > node.Data) ? node.Data : Top.Min; node.Next = Top; } Top = node; }
public void Push(T data) { if (_top == null) { _top = new StackNode <T>(data); } else { StackNode <T> temp = _top; _top = new StackNode <T>(data) { Next = temp }; } }
public T Pop() { if (this.Count <= 0) { throw new InvalidOperationException("Stack is empty"); } var first = this.firstNode; this.firstNode = this.firstNode.NextNode; this.Count--; return(first.Value); }
public void Push(T item) { var newTop = new StackNode <T>(item); if (top == null) { top = newTop; top.Minimum = item; } else { newTop.Next = top; newTop.Minimum = item.CompareTo(top.Minimum) < 0 ? item : top.Minimum; top = newTop; } }
public void Push(T value) { var node = new StackNode <T>(value); if (this.Count == 0) { this.firstNode = node; } else { node.NextNode = this.firstNode; this.firstNode = node; } this.Count++; }
protected override void RenderInternal(IRenderContext context) { StackContainer panel = new StackContainer(modelDefinition); context.Add(panel); foreach (IFieldDefinition fieldDefinition in modelDefinition.Fields) { StackNode node = new StackNode(fieldDefinition); panel.Children.Add(node); IFieldView <IRenderContext> fieldView = fieldViewProvider.Get(modelDefinition, fieldDefinition); AddFieldView(fieldDefinition.Identifier, fieldView); node.FieldView = fieldView; } }
public double pop() { double val = head.Data; head = head.Previous; //Min if (helper != null) { if (helper.Data == val) { helper = helper.Previous; } } return val; }
public void Push(int val) { var node = new StackNode(); node.value = val; if (stack.Count > 0) { node.minValue = Math.Min(stack.Peek().minValue, val); } else { node.minValue = val; } stack.Push(node); }
public int Pop() { if (_top == null) { throw new InvalidOperationException("Stack is empty."); } int item = _top.Data; _top = _top.Below; if (item == _minStack.Peek()) { _minStack.Pop(); } return(item); }
public int Pop() { int popped = int.MinValue; if (root == null) { Console.WriteLine("Stack is Empty."); } else { popped = root.data; root = root.next; } Console.WriteLine(popped + " is popped out from Stack."); return(popped); }
static void Main(string[] args) { //Creacion de la pila Stack stack = new Stack(); //Creacion de nodos StackNode sn1 = new StackNode(5); StackNode sn2 = new StackNode(4); StackNode sn3 = new StackNode(9); StackNode sn4 = new StackNode(13); StackNode sn5 = new StackNode(7); StackNode sn6 = new StackNode(3); //Inserción de nodos stack.Push(sn1); stack.Push(sn2); stack.Push(sn3); }
public string pop() { if (top.stack == null) { throw new InvalidOperationException(message: "Stacks are empty"); } else { string returnValue = top.stack.Pop(); if (top.stack.Count == 0 && top.next != null) { top = top.next; } return(returnValue); } }
public double pop() { double val = head.Data; head = head.Previous; //Min if (helper != null) { if (helper.Data == val) { helper = helper.Previous; } } return(val); }
/// <summary> /// Method for pushing node to top of stack, also sets node as stack min if it is smaller than all the other nodes /// O(1) time and space /// </summary> /// <param name="data"></param> public void Push(int data) { StackNode pushedNode = new StackNode(data); pushedNode.Next = Top; Top = pushedNode; if (Min == null) { Min = pushedNode; } else if (pushedNode.Data < Min.Data) { pushedNode.NextMin = Min; Min = pushedNode; } }
public void Push(int data) { StackNode newNode = new StackNode(data); if (root == null) { root = newNode; } else { StackNode temp = root; root = newNode; newNode.next = temp; } Console.WriteLine(data + " pushed into the stack."); }
public void push(int num) { var newnode = new StackNode { data = num }; if (root == null) { root = newnode; } else { StackNode temp = root; root = newnode; newnode.next = temp; } }
private void FindNewMin() { var current = _top; var min = _top; while (current != null) { if (current.value < min.value && !object.ReferenceEquals(current, min)) { min = current; } current = current.next; } _min = min; }
public T removeBottom() { if (!isEmpty()) { size--; T item = bottom.data; bottom = bottom.above; if (bottom != null) { bottom.below = null; } return(item); } else { throw new NullReferenceException(); } }
/// <summary> /// Method for removing a node off the top of the stack and returning the val. If node is also stack min, then changes min to next smallest node /// O(1) time and space /// </summary> /// <returns></returns> public int Pop() { if (Top == null) { throw new Exception("Stack is empty."); } StackNode poppedNode = Top; Top = Top.Next; if (poppedNode == Min) { Min = Min.NextMin; } return(poppedNode.Data); }
public void Reverse() { StackNode prev, cur, succ; cur = prev = top; cur = cur.next; prev.next = null; while (cur != null) { succ = cur.next; cur.next = prev; prev = cur; cur = succ; } top = prev; }
/// <summary> /// 새로운 요소를 Stack에 추가합니다. /// </summary> /// <param name="item"></param> public void Push(T item) { if (IsDebugEnabled) { log.Debug("새로운 요소를 Stack에 추가합니다. item=[{0}]", item); } var node = new StackNode <T>(item); StackNode <T> current; do { current = _head; node.Next = current; #pragma warning disable 0420 } while(_head != current || Interlocked.CompareExchange(ref _head, node, current) != current); #pragma warning restore 0420 }
public string popAt(int n) { StackNode temp = top; for (int i = 1; i < n; i++) { if (temp.next != null) { temp = temp.next; } else { throw new InvalidOperationException(message: $"Stack {n} does not exist."); } } return(temp.stack.Pop()); }
public void Push(int x) { int currTopMin = stack.Count > 0 ? stack.Peek().MinVal : int.MaxValue; // When pushing our new value in the stack see // if it starts a new minimum value. If so, we set a // different MinVal in this StackNode. StackNode newNode = new StackNode { Val = x, MinVal = currTopMin }; if (x < currTopMin) { newNode.MinVal = x; } stack.Push(newNode); }
/// <summary> /// It return the number of element present in stack. /// </summary> /// <returns></returns> public int Size() { int count = 0; if (top == null && bottom == null) { return(count); } else { for (StackNode p = top; p != null; p = p.next) { count++; } return(count); } }
public override void Push(int value) { var node = new StackNode(value); if (_min == null) { _min = node; } else { if (_min.value >= value) { _min = node; } } Push(node); }
public override void SetUp() { base.SetUp(); m_Node1 = CreateNode("Node 1", new Vector2(100, 100), 2, 2); m_Node2 = CreateNode("Node 2", new Vector2(200, 200), 2, 2); m_Node3 = CreateNode("Node 3", new Vector2(400, 400)); m_Node4 = CreateNode("Node 4", new Vector2(500, 500)); m_Group = CreateGroup("Group", 500, 0); m_StackNode = CreateStackNode(300, 300); m_Edge1 = CreateEdge(m_Node2.outputContainer[0] as Port, m_Node1.inputContainer[0] as Port); m_Edge2 = CreateEdge(m_Node2.outputContainer[1] as Port, m_Node1.inputContainer[0] as Port); m_Group.AddElement(m_Node2); m_StackNode.AddElement(m_Node3); m_StackNode.AddElement(m_Node4); }
public int pop() { if (top == null) { throw new InsufficientExecutionStackException(); } int item = top.value; top = top.next; // define min if (item == minimum) { minList.Pop(); } return(item); }
/// <summary> /// It Push the data on to the stack. /// </summary> /// <param name="data"></param> public void Push(string data) { StackNode stackNode = new StackNode(); if (top == null) { stackNode.data = data; stackNode.next = null; top = stackNode; bottom = stackNode; } else { stackNode.data = data; stackNode.next = null; bottom.next = stackNode; bottom = stackNode; } }
public void push(double val) { //Min if (helper != null) { if (helper.Data > val) { StackNode h = new StackNode(val); h.Previous = helper; helper = h; } } else { StackNode h = new StackNode(val); h.Previous = helper; helper = h; } StackNode sn = new StackNode(val); sn.Previous = head; head = sn; }
// Remove all stack datas public void Clear() { this.count = 0; this.top = new StackNode(null); }
public StackNode(int stateIndex, StackNode prev, object value) { StateIndex = stateIndex; PrevNode = prev; ReducedValue = value; }
private IEnumerator GetEnumerator(StackNode n) { while (n != null) { yield return n.Value; n = n.Prev; } }
public void push(int target, double val) { Used++; arr[Used] = val; StackNode sn = new StackNode(Used); sn.Previous = Pointers[target]; Pointers[target] = sn; }
// Implement the push operation public void Push(object data) { StackNode stackNode = new StackNode(data); stackNode.Next = this.top.Next; this.top.Next = stackNode; this.count++; }
// Initializing constructor public StackNode(object dataValue) { this.data = dataValue; this.next = null; }
// Default constructor public LinkedStack() { this.count = 0; this.top = new StackNode(null); }
private StackNode top; // reference to the top of this stack public LinkedStack() { top = null; }
internal StackNode(object value, StackNode prev = null) { Value = value; Prev = prev; Count = prev != null ? prev.Count + 1 : 1; }
public int pop() { if(head==null) { return int.MinValue; } StackNode temp=head; head=head.next; return temp.data; }
public double pop() { if (head == null) { return -1; } double val = head.Data; head = head.Previous; size--; return val; }
public void push(int i) { StackNode n=new StackNode(i); if(head==null) { head=n; return; } n.next=head; head=n; }
public void push(double val) { StackNode sn = new StackNode(val); sn.Previous = head; head = sn; size++; }
public StackNode(int i) { data=i; next=null; }
public Stack() { head=null; }
public void push(object item) { var node = new StackNode {info = item, link = top}; top = node; }