zoukankan      html  css  js  c++  java
  • 【数据结构 JavaScript版】- web前端开发精品课程【红点工场】--javascript--栈的概念

    <!DOCTYPE html>
    <html>
    
    <head>
        <title></title>
    </head>
    
    <body>
        <script>
        // 【数据结构 JavaScript版】- web前端开发精品课程【红点工场】--javascript--栈的概念
        // javascript 栈的概念 
        // push() 进栈,从栈顶出栈
        // pop() 出栈,从栈顶进栈
        // peek() 查看栈顶元素
        // siEmpty() 检查是否为空
        // clear() 移除全部元素
        // size() 获取栈的长度
        var Stack = function() {
            var items = []; //对象是有成员
            // this.items = []; items将变成公有属性
            // items = [];
            // push(1);  items = [1];
            // push(2)  items = [1,2] 1为栈底
            this.push = function(element) {
                items.push(element)
            }
            this.getItems = function() {
                return items;
            }
    
            // 获取items最后一项
            this.peek = function() {
                return items[items.length - 1];
            }
            //  items = [1,2,3];
            // items.pop();  ==3     items = [1,2];
            this.pop = function() {
                return items.pop();
            }
    
            // items 长度为0 则为true
            this.isEmpty = function() {
                return items.length == 0
            }
            // 将items置空
            this.clear = function() {
                items = [];
            }
           
            // 返回items的长度
            this.size = function() {
                return items.length;
            }
        }
        </script>
    </body>
    
    </html>
    

      

  • 相关阅读:
    Hive
    Hadoop简介与分布式安装
    Hadoop分布式文件系统HDFS
    HDFS的操作SHELL和API
    HDFS高级功能
    Yarn
    Hadoop的I/O操作
    Hadoop的RPC工作原理
    Mapreduce入门和优化方案
    MapReduce的工作机制
  • 原文地址:https://www.cnblogs.com/SunlikeLWL/p/10120988.html
Copyright © 2011-2022 走看看