var createList= function(){
var _this = {},
first = null;
_this.length = 0;
_this.add = function(val) {
first = {data:val, next: first || null};
_this.length++;
}
_this.del = function(val){
if (first.data == val){
first = first.next;
return ;
}
var ptemp = temp = first;
for( ; temp; ptemp = temp ,temp= temp.next){
if(temp.data == val){
ptemp.next = temp.next;
_this.length--;
return ;
}
}
}
_this.get = function(val){
for( var temp = first ; temp; temp= temp.next){
if(temp.data == val){
alert( temp )
}
}
}
_this.each= function(fn) {
for(temp=first;temp;temp=temp.next) {
fn(temp.data);
}
}
return _this;
}
var _this = {},
first = null;
_this.length = 0;
_this.add = function(val) {
first = {data:val, next: first || null};
_this.length++;
}
_this.del = function(val){
if (first.data == val){
first = first.next;
return ;
}
var ptemp = temp = first;
for( ; temp; ptemp = temp ,temp= temp.next){
if(temp.data == val){
ptemp.next = temp.next;
_this.length--;
return ;
}
}
}
_this.get = function(val){
for( var temp = first ; temp; temp= temp.next){
if(temp.data == val){
alert( temp )
}
}
}
_this.each= function(fn) {
for(temp=first;temp;temp=temp.next) {
fn(temp.data);
}
}
return _this;
}