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());
}
网友评论