A Li

作者: flykimmy | 来源:发表于2017-06-19 16:23 被阅读0次


functionLists() {

this.listSize=0;

this.positions=0;

this.dataSource=[];

this.appends=Appends;

this.finds=Finds;

this.removes=Removes;

this.lengths=Lengths;

this.tostrings=ToStrings;

this.inserts=Inserts;

this.clears=Clears;

this.contains=Contains;

this.fronts=Fronts;

this.end=End;

this.prev=Prev;

this.nexts=Next;

this.currpos=CurrPos;

this.moveto=MoveTo;

this.getelement=GetElement;

}

functionAppends(e) {

this.dataSource[this.listSize++]=e;

}

functionFinds(e) {

for(vari=0;i

if(this.dataSource[i]==e){

returni;

}

}

return-1;

}

functionRemoves(e) {

varfindAt=this.finds(e)

if(findAt>-1){

this.dataSource.splice(findAt,1);

this.listSize--;

return true;

}

return false;

}

functionLengths() {

return this.listSize;

}

functionToStrings() {

return this.dataSource;

}

functionInserts(e,after) {

varinsertPos=this.finds(after);

if(insertPos>-1){

this.dataSource.splice(insertPos+1,0,e);

this.listSize++;

return true;

}

return false;

}

functionClears() {

delete this.dataSource;

this.dataSource=[];

this.listSize=this.positions=0;

}

functionContains(e) {

for(vari=0;i

if(this.dataSource[i]==e){

return true;

}

}

return false;

}

functionFronts() {

this.positions=0;

}

functionEnd() {

this.positions=this.listSize-1;

}

functionPrev() {

if(this.positions>0){

this.positions--;

}else{

this.positions=-1;

}

}

functionNext() {

if(this.positions

this.positions++;

}else{

this.positions=9999999;

}

}

functionCurrPos() {

return this.positions;

}

functionMoveTo(p) {

this.positions=p;

}

functionGetElement() {

return this.dataSource[this.positions];

}

varnames=newLists();

names.appends("Clayton");

names.appends("Raymond");

names.appends("Cyntthia");

names.appends("Jennifer");

names.appends("Bryan");

names.appends("Danny");

names.fronts();

for(names.fronts();names.currpos()

console.log(names.getelement());

}

console.log("*****************************************************************************************")

for(names.end();names.currpos()>=0;names.prev()){

console.log(names.getelement());

}

相关文章

网友评论

      本文标题: A Li

      本文链接:https://www.haomeiwen.com/subject/pjzgqxtx.html