博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
数据结构之列表
阅读量:3889 次
发布时间:2019-05-23

本文共 1014 字,大约阅读时间需要 3 分钟。

function List () {
// 初始化 this.dataStore = []; this.listSize = 0; this.pos = 0; // 当前的位置,默认为0 this.length = length; // 返回列表的长度 this.clear = clear; // 清空列表元素 this.getCurrElement = getCurrElement; // 获取当前元素 this.insert = insert; // 在某一元素的后面插入一个元素 this.append = append; // 在列表末尾添加新元素 this.find = find; // 这个是辅助方法,用于查找列表中有无某个元素 this.toString = toString; // 返回当前的列表,查看元素 } function find (ele) {
for (let i = 0;i
-1) {
this.dataStore.splice(pos + 1, 0, after); this.listSize++; // 插入元素之后,列表长度加一 return true; } return false; } function toString () {
return this.dataStore.toString(); } const list = new List(); list.append(1); list.append(2); console.log(list.length()); list.insert(1, 121); console.log(list.toString());

转载地址:http://ygthn.baihongyu.com/

你可能感兴趣的文章
智能硬件开发如何选择低功耗MCU?
查看>>
阿里感悟(十)如何写好简历
查看>>
阿里感悟(十一)如何准备面试
查看>>
软件架构入门
查看>>
80 多个 Linux 系统管理员必备的监控工具
查看>>
OOD的原则
查看>>
Tool to trace local function calls in Linux
查看>>
Linux 下查询 DNS 服务器信息
查看>>
ulimit 里的 file size 的 block 单位是多少?
查看>>
linux下查看端口对应的进程
查看>>
将 gdb 用作函数跟踪器 (Function Tracer)
查看>>
原 GCC一些有用的技巧
查看>>
yum 变量追加的方法
查看>>
2倍速的下一代Bluetooth,「Bluetooth 5」发布
查看>>
Top 10 “Yum” installables to be productive as a developer on Red Hat Enterprise Linux
查看>>
[小技巧] Vim 如果去除 “existing swap file” 警告
查看>>
如何在linux下检测内存泄漏
查看>>
十年生聚,Vim 8.0 发布了!
查看>>
【演歌】加賀の女 歌词翻译
查看>>
東京音頭 (东京音头) 歌词翻译
查看>>