Skip to content

Commit

Permalink
Update linked-list.js
Browse files Browse the repository at this point in the history
  • Loading branch information
ALX51 authored Sep 26, 2017
1 parent a3ac1fc commit d8d967e
Showing 1 changed file with 60 additions and 13 deletions.
73 changes: 60 additions & 13 deletions src/linked-list.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,74 @@
const Node = require('./node');
//не понял условие продерки метода append ( _head, _tail)

class LinkedList {
constructor() {}
class LinkedList extends Node {
constructor() {
super()
this.arr = [];
this.length = this.arr.length;
}

append(data) {}
append(data) {
this.arr.push(data);
this.length = this.arr.length;
return this;

}

head() {}
head() {
if (this.arr[0]) {
return this.arr[0];
} else {
return null;
}
}

tail() {}
tail() {
if (this.arr[this.arr.length - 1]) {
return this.arr[this.arr.length - 1];
} else {
return null;
}
}

at(index) {}
at(index) {
return this.arr[index];
}

insertAt(index, data) {}
insertAt(index, data) {
this.arr[index] = data;
this.length = this.arr.length;
return this;
}

isEmpty() {}
isEmpty() {
if (this.arr == 0) {
return true;
} else {
return false;
}
}

clear() {}
clear() {
this.length = 0;
this.arr.length = 0;
return this;
}

deleteAt(index) {}
deleteAt(index) {
this.arr.splice(index, 1);
this.length = this.arr.length;
return this;
}

reverse() {}
reverse() {
Array.prototype.reverse.call(this.arr);
return this;
}

indexOf(data) {}
indexOf(data) {
return this.arr.indexOf(data);
}
}

module.exports = LinkedList;
module.exports = LinkedList;

0 comments on commit d8d967e

Please sign in to comment.