JavaScript数据结构形貌

1.列表

1.1 完成列表类

定义组织函数:

function List() {
    this.listSize = 0;
    this.pos = 0;
    this.dataStore = [];
    this.clear = clear;
    this.find = find;
    this.toString = toString;
    this.insert = insert;
    this.append = append;
    this.remove = remove;
    this.front = front;
    this.end = end;
    this.prev = prev;
    this.next = next;
    this.hasNext;
    this.hasPrev;
    this,length = length;
    this.currPos = currPos;
    this.moveTo = moveTo;
    this.getElement = getElement;
    this.contains = contains;  

1.1.2 append

function append(element){
    this.dataStore[this.listSize++] = element;
}
    原文作者:太宰夜
    原文地址: https://segmentfault.com/a/1190000007465166
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞