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

列表

 

List

function List(){
     this.dataStore = 0;
    this.insert = insert;
    this.find = find;
    this.append = append;
    this.remove = remove;

//插入 function insert(element, after) { var insertPos = this.find(after); if (insertPos > -1) { this.dataStore.splice(insertPos + 1, 0, element); ++this.listSize; return true; } return false; } //查找 function find(element) { for (var i = 0; i < this.dataStore.length; ++i) { if (this.dataStore[i] == element) { return i; } } return -1; } //数据末尾插入 function append(element) { this.dataStore[this.listSize++] = element; }
//删除 function remove(element) { var foundAt = this.find(element); if (foundAt > -1) { this.dataStore.splice(foundAt, 1); --this.listSize; return true; } return false; }
}

  

from:https://blog.csdn.net/haoshidai/article/details/52263191

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