• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
向阳光大道勇猛前进吧,了解但不走偏门!
            管理     

栈

function Stack() {
    this.dataStore = []; //底层数据结构是数组
    this.top = 0; //top应该是等于数组的length的
    this.push = push;
    this.pop = pop;
    this.peek = peek;


function push(element) {
    this.dataStore[this.top++] = element;
}

function pop() {
    return this.dataStore[--this.top];
}


function peek() {
    return this.dataStore[this.top-1];
}


}

 

 

链接:https://blog.csdn.net/haoshidai/article/details/52263191

 

圣凡无二路,方便有多门。
posted @ 2018-09-02 11:14  优昙陀罗  阅读(113)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3