首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏分享学习

    stack栈和stack栈数组

    声明一个stackstack<int> s1; stack<string> s2; stack中的操作 stack<int> s; s.push(x) 无返回值 s.empty()) { s.pop(); } 声明一个stack栈数组 #include<iostream> #include<string> #include <stack> using namespace std; int main() { stack<int>a[10]; //声明一个栈的数组 for(int i=0;i<10;i++)

    50620发布于 2020-03-23
  • 来自专栏友弟技术工作室

    Stack

    stack 下面看下Java的stack源码, 具体API使用,我就不介绍了。 an empty Stack. */ public Stack() { } /** * Pushes an item onto the top of this stack. 下面使用 go 实现一个 package stack import ( "container/list" ) // stack struct type Stack struct { list *list.List } // get a stack func NewStack() *Stack { list := list.New() return &Stack{list

    65040发布于 2021-05-06
  • 来自专栏算法

    栈(Stack

    (下划线来暗示其他看代码的人这是变量,也是与C++中的类与对象接轨) typedef int STDataType; typedef struct Stack { STDataType* _a; int _top; // 栈顶 int _capacity; // 容量 }Stack; 任何数据结构的基本功能都只有几个——插入、调整、删除、销毁,也就是所谓的增删查改。 // 入栈 void StackPush(Stack* ps, STDataType data) { int NewCapacity = 0; STDataType* mid = NULL; void StackPop(Stack* ps) { assert(ps->_top + 1); ps->_top--; } 删除数据就更加简单了。 // 获取栈中有效元素个数 int StackSize(Stack* ps) { return ps->_top + 1; } 好的,本期分享到这里就结束了,感谢各位的捧场!

    12110编辑于 2025-12-30
  • 来自专栏生如夏花绚烂

    栈(stack

    最后放入的元素在栈顶,而删除元素刚好相反,最后放入的元素是先删除,最先放入的元素后删除 入栈与出栈示意图 数组模拟栈 定义一个Top来表示栈顶,初始化为 -1 入栈的操作:当有数据入栈时,top++;stack [top] = data 出栈的操作:当弹出数据时,int value = stack[top];top--return value 代码实现 class ArrayStack{ private int maxSize; private int[] stack; //栈数组 private int top = -1; //栈顶 public ArrayStack(int maxSize){ this.maxSize = maxSize; stack = new int[maxSize]; } //判断栈是否满 public [%d]=%d\n",i,stack[i]); } } }

    74020编辑于 2022-09-14
  • 来自专栏对线JAVA面试

    栈(Stack)

    栈(Stack)是一种后进先出的数据结构(LIFO:last in first out),只允许访问栈中的第一个数据项:即最后插入的数据项。移除这个数据项之后,才能看到第二个数据项,以此类推。 往栈中存入数据称之为压栈(push),移除数据称之为弹栈(pop),此外通常还提供查看栈顶元素的peek方法,此方法可以可以栈顶元素的值,但是并不会将其移除 java.util.Stack就是JDK提供的一种对栈的实现 运行程序输出 push: 0 1 2 3 4 5 6 7 8 9 pop: 9 8 7 6 5 4 3 2 1 0 可以看到数据都是按照和插入顺序相反的方式弹出来了 基于链表的栈的实现 基于链表的Stack

    47130编辑于 2022-10-27
  • 来自专栏Elastic Stack专栏

    窥探Stack Overflow & Stack Exchange 的基础架构

    Stack Overflow 对于广大的程序员来说应该并不陌生,当我们google一些开发相关问题时,被导航到Stack Overflow 的概率是非常高的。 其实不仅仅是Stack Overflow ,他们的另一款产品 Stack Exchange 也可帮助人们在需要时找到所需的答案。 整个Stack Exchange Network由包括 Stack Overflow 在内的 173 个问答社区组成,每月有超过 1 亿人访问以提问、学习和分享技术知识。 这些产品包括Stack Overflow for Teams、Stack Overflow Advertising、Collectives™ on Stack Overflow和Stack Overflow 我们可以从Stack Exchange公布的架构图可见一斑。大量的内存消耗,意味着为了满足高吞吐低延迟的访问,大量的数据平时都是被放在内存中的。

    2.3K62编辑于 2022-07-10
  • 来自专栏Jack-Cui

    155.Min StackStack-Easy)

        Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) – Push element x onto stack. pop() – Removes the element on top of the stack. top() – Get the top element. getMin() – Retrieve the minimum element in the stack. 题目: 设计一个支持push、pop、top和能返回最小值stack中最小值的stack 思路: 创建两个stack,一个保存所有元素,一个负责保存最小元素。 Language : cpp class MinStack { public: /** initialize your data structure here. */ stack<int

    66550发布于 2018-01-08
  • 来自专栏iSharkFly

    Pulumi Stack 命令不能找到默认的 Stack

    当我们对 Token 进行更换后,你会发现 使用命令 ‘pulumi stack ls’ 查看当前项目的 stack 一直访问的是老的 stack。 https://www.ossez.com/t/pulumi-stack-stack/13495

    68600发布于 2021-06-05
  • 来自专栏CoffeeLand

    Stack Stracture

    Stack definition stack是限定仅在表尾进行插入和删除操作的线性表 或者 stack是限定在只能在栈顶进行插入和删除操作的线性表 Stack Features Last in First Out Underlying principle inside the stack stack是一个有顺序的线性表,既然是线性表,底层是数组, Because stack是Last in first 因此数组的index是0最适合做栈底, 因为变化最小 Source code of the Stack ---- Stack class Diagram class Stack<E> extends Vector<E> image.png Stack Method image.png Implement stack structure with Java package com.coffeland.test ; public class Stack { int Max = 5; int top; Object[] arr = new Object[5]; Stack(int

    45110发布于 2020-03-04
  • 来自专栏Golang开发

    Stack

    public interface Stack<Item> { int getSize(); boolean isEmpty(); void push(Item e); Item } @Override /** * 压栈 */ public void push(Item e) { if (size()== stack.length ){ expandCapacity(); } stack[top]=e; top++; } /** * 栈扩容 */ private void expandCapacity(){ stack = Arrays.copyOf(stack,stack.length*2); if (isEmpty()) throw new EmptyStackException(); top--; Item item = stack

    45820发布于 2019-05-28
  • 来自专栏书山有路勤为径

    Navigation Stack

    Navigation Stack是一个ROS的metapackage,里面包含了ROS在路径规划、定位、地图、异常行为恢复等方面的package,其中运行的算法都堪称经典。 Navigation Stack的主要作用就是路径规划,通常是输入各传感器的数据,输出速度。一般我们的ROS都预装了Navigation。 Navigation Stack的源代码位于https://github.com/ros-planning/navigation,包括了以下几个package: ? 工作框架 ? 而每一个插件其实也都是一个package,放在Navigation Stack里。 关于move_base我们后面会进一步介绍,先来看看 move_base外围有哪些输入输出。 还有一个costmap插件,该插件默认已经选择好,默认即为costmap_2d,不可更改,但costmap_2d提供了不同的Layer可以供我们设置 costmap costmap是Navigation Stack

    1.4K41发布于 2019-05-17
  • 来自专栏caoqi95的记录日志

    Stack - 栈

    为了去野外烧烤,你创建了一堆的任务清单 - 一叠便条。对一叠便条会有如下操作:插入的待办事项放在清单的最前面;读取待办事项时,只读取最上面的,并将其删除。一叠便条就是栈,插入对应着栈的压入操作,读取并删除对应着栈的弹出操作。

    60010发布于 2019-03-27
  • 来自专栏SnailTyan

    Min Stack

    . push(x) – Push element x onto stack. pop() – Removes the element on top of the stack. top() – Get the top element. getMin() – Retrieve the minimum element in the stack. class MinStack { private Stack<Integer> stack = new Stack<>(); private Stack<Integer> minStack if(stack.peek().equals(minStack.peek())) { minStack.pop(); } stack.pop();

    85710发布于 2019-05-25
  • 来自专栏学习笔记持续记录中...

    栈(stack)

    public class ArrayStackDemo { public static void main(String[] args) { ArrayStack stack = new ArrayStack(4); for(int i = 0;i < 5;i++){ stack.push(i); } stack.list (); System.out.println(stack.pop()); System.out.println(stack.pop()); System.out.println (stack.pop()); System.out.println(stack.pop()); System.out.println(stack.pop()); [%d] = %d \n",i,stack[i]); } } }

    44110发布于 2020-03-17
  • 栈(Stack

    [] args) { Stack<Integer> stack = new Stack<>(); stack.push(1); stack.push(2) ; stack.push(3); stack.push(4); stack.push(5);//以上为压栈操作 Integer x = stack.peek stack.empty() && stack.peek() == popV[j]){ stack.pop(); j++; Stack<Integer> minStack; public MinStack() { stack = new Stack<>(); minStack = new Stack<>(); } public void push(int val) { //不论是第几次入栈,stack都要入栈 stack.push

    16710编辑于 2026-01-12
  • 来自专栏Jack-Cui

    Implement Stack using Queues(Stack-Easy)

    Implement the following operations of a stack using queues. push(x) – Push element x onto stack. pop( ) – Removes the element on top of the stack. top() – Get the top element. empty() – Return whether the stack is empty. assume that all operations are valid (for example, no pop or top operations will be called on an empty stack the top element. */ int top() { return que.front(); } /** Returns whether the stack

    594100发布于 2018-01-08
  • 来自专栏web全栈

    Elastic Stack——Elastic Stack简介和Elasticsearch核心详解

    1、Elastic Stack简介 如果你没有听说过Elastic Stack,那你一定听说过ELK,实际上ELK是三款软件的简称,分别是Elasticsearch、 Logstash、Kibana组成 ,在发展的过程中,又有新成员Beats的加入,所以就形成了Elastic Stack。 所以说,ELK是旧的称呼,Elastic Stack是新的名字。

    2.4K30编辑于 2022-09-24
  • 来自专栏吉林乌拉

    Stack源码解

    在这一篇中我们继续介绍另一种底层也是用数据方式实现的集合,它就是Stack集合。Stack与ArrayList和Vector相比,有自己独特的一些特性。 正是因为Stack有自己独特的特性,所以在使用上Stack与ArrayList、Vector相比有些区别,所以下面我们先了解一下Stack集合的基本使用,然后在分析Stack集合的底层源码。 Stack也就是栈,它和其它集合相比它的特性就是后进先出,也就是后添加到Stack集合中的元素,会被添加到栈的最顶位置。下面我们看一下在Stack集合中的都包括哪些方法。 ? 下面我们分析一下Stack集合的底层源码,还是和ArrayList集合和Vector集合一样,我们先看一下Stack集合的初始化。 ? 这是因为Stack集合是Vector集合的子类,也就是Stack集合默认继承了Vector集合。下面是底层源码。 ?

    75620发布于 2019-08-14
  • 来自专栏乐意学点小编程

    【C++】Stack

    一、Stack的介绍和使用 1、stack的介绍 stack详细解释 stack是一种容器适配器,专门用来处理后进先出操作,其删除只能从容器的一端进行元素的插入和提取操作 stack是作为容器适配器被实现的 ,如果没有指定stack的底层容器,默认为deque,这其中只有deque没有学习过,后面拿一个段落专门解释deque 2、stack的使用 函数说明 接口说明 stack 构造空的栈 empty 检测 stack是否为空 size 返回stack中的元素个数 top 返回栈顶元素的引用 push 将元素val压入stack中 pop 将stack中尾部的元素弹出 void test_stack() { stack<int> st; st.push(1); st.push(2); st.push(3); st.push(4); while (! little_monster { template<class T,class Container = std::deque<T>> class stack { public: stack

    40110编辑于 2024-09-13
  • 来自专栏csdn_blog

    Stack.peek() 与 Stack.pop() 的区别

    相同点:都返回栈顶的值。 不同点:peek() 不改变栈的值(不删除栈顶的值),pop() 会把栈顶的值删除。

    1.3K30发布于 2020-09-22
领券