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.length = length;
this.currPos = currPos;
this.moveTo = moveTo;
this.getElement = getElement;
this.contains = contains;
}
function print(){
this.dataStore.map(item=>console.log(item))
}
function toString(){
return this.dataStore.toString();
}
function append(val){
this.dataStore[this.listSize++] = val
}
function remove(val){
if(this.find(val)!==-1){
this.dataStore.splice(this.find(val),1)
this.listSize--
return true
}
return false
}
function find(val){
for(let i = 0 ;i<this.dataStore.length;i++){
if(this.dataStore[i] === val){
return i
}
}
return -1
}
function length(){
return this.listSize
}
function insert(val,after){
let afterIndex = this.find(after)
if(afterIndex > -1){
this.dataStore.splice(afterIndex + 1,0,val)
this.dataStore.length++
return true
}
return false
}
function clear(){
this.dataStore = []
this.listSize = 0
this.pos = 0
}
function contains(val){
for(let i = 0 ;i<this.dataStore.length;i++){
if(this.dataStore[i] === val){
return true
}
}
return false
}
function currPos(){
return this.pos
}
function front(){
this.pos = 0
}
function end(){
this.pos = this.listSize - 1
}
function prev(){
if(this.pos>0){
this.prev--
}
}
function next(){
if(this.pos <this.listSize - 1 ){
this.pos++
}
}
function getElement(){
return this.dataStore[this.pos]
}
function moveTo(index){
if(index<0 || index>this.listSize - 1){
return
}
this.pos = index
return this.dataStore[index]
}
function diedaiqi(){
for(this.currPos();this.currPos()<this.end();this.next()){
print(this.getElement())
}
for(this.end();this.currPos()>=0;this.prev()){
print(this.getElement())
}
}
function insertVal(nums,val){
if(nums.every(item=>item<val)){
nums.push(val)
}
}
function BookPersonOP(){
this.book = []
this.preson = []
this.bookPersonOP = {'hyh':['232']}
}
console