Skip to content

Commit 9b498cb

Browse files
😒 chore: Patch sources.
1 parent 5f89a67 commit 9b498cb

File tree

2 files changed

+30
-30
lines changed

2 files changed

+30
-30
lines changed

src/DoublyLinkedList.js

+29-30
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,30 @@
44
* sake of simplicity.
55
*/
66

7-
var DoublyLinkedList = function(){
7+
export function DoublyLinkedList(){
88
this.front = new Node(null, null, null);
99
this.back = new Node(this.front, null, null);
1010
this.front.next = this.back;
1111
this.length = 0;
12-
};
12+
}
1313

14-
var Node = function(prev, next, value){
14+
export function Node(prev, next, value){
1515
this.prev = prev;
1616
this.next = next;
1717
this.value = value;
18-
};
18+
}
1919

20-
var Iterator = function(front, back, current){
20+
export function Iterator(front, back, current){
2121
this.front = front;
2222
this.back = back;
2323
this.current = current;
24-
};
24+
}
2525

26-
var ReverseIterator = function(front, back, current){
26+
export function ReverseIterator(front, back, current){
2727
this.front = front;
2828
this.back = back;
2929
this.current = current;
30-
};
30+
}
3131

3232
DoublyLinkedList.prototype.insertAfter = function(iterator, value){
3333
var node, prev;
@@ -40,7 +40,7 @@ DoublyLinkedList.prototype.insertAfter = function(iterator, value){
4040

4141
++this.length;
4242
return this.iterator(node);
43-
};
43+
}
4444

4545
DoublyLinkedList.prototype.insertBefore = function(iterator, value){
4646
var node, next;
@@ -53,15 +53,15 @@ DoublyLinkedList.prototype.insertBefore = function(iterator, value){
5353

5454
++this.length;
5555
return this.iterator(node);
56-
};
56+
}
5757

5858
DoublyLinkedList.prototype.unshift = function(value){
5959
return this.insertAfter(this.begin(), value);
60-
};
60+
}
6161

6262
DoublyLinkedList.prototype.push = function(value){
6363
return this.insertBefore(this.end(), value);
64-
};
64+
}
6565

6666
DoublyLinkedList.prototype.erase = function(iterator){
6767
var node = iterator.current;
@@ -71,7 +71,7 @@ DoublyLinkedList.prototype.erase = function(iterator){
7171

7272
--this.length;
7373
return this.iterator(node.next);
74-
};
74+
}
7575

7676
DoublyLinkedList.prototype.rerase = function(iterator){
7777
var node = iterator.current;
@@ -81,7 +81,7 @@ DoublyLinkedList.prototype.rerase = function(iterator){
8181

8282
--this.length;
8383
return this.iterator(node.prev);
84-
};
84+
}
8585

8686
DoublyLinkedList.prototype.eraserange = function(first, last){
8787
var firstnode, lastnode, it;
@@ -98,7 +98,7 @@ DoublyLinkedList.prototype.eraserange = function(first, last){
9898
it.next();
9999
}
100100
return last.copy();
101-
};
101+
}
102102

103103
DoublyLinkedList.prototype.reraserange = function(first, last){
104104
var firstnode, lastnode, it;
@@ -115,7 +115,7 @@ DoublyLinkedList.prototype.reraserange = function(first, last){
115115
it.next();
116116
}
117117
return last.copy();
118-
};
118+
}
119119

120120
DoublyLinkedList.prototype.shift = function ( ) {
121121

@@ -130,7 +130,7 @@ DoublyLinkedList.prototype.shift = function ( ) {
130130

131131
return node.value ;
132132

133-
} ;
133+
}
134134

135135
DoublyLinkedList.prototype.pop = function ( ) {
136136

@@ -145,46 +145,46 @@ DoublyLinkedList.prototype.pop = function ( ) {
145145

146146
return node.value ;
147147

148-
} ;
148+
}
149149

150150
DoublyLinkedList.prototype.clear = function(){
151151
this.front.next = this.back;
152152
this.back.prev = this.front;
153153
this.length = 0;
154154
return this;
155-
};
155+
}
156156

157157
DoublyLinkedList.prototype.iterator = function(node){
158158
return new Iterator(this.front, this.back, node);
159-
};
159+
}
160160

161161
DoublyLinkedList.prototype.riterator = function(node){
162162
return new ReverseIterator(this.front, this.back, node);
163-
};
163+
}
164164

165165
DoublyLinkedList.prototype.begin = function(){
166166
return this.iterator(this.front);
167-
};
167+
}
168168

169169
DoublyLinkedList.prototype.end = function(){
170170
return this.iterator(this.back);
171-
};
171+
}
172172

173173
DoublyLinkedList.prototype.rbegin = function(){
174174
return this.riterator(this.back);
175-
};
175+
}
176176

177177
DoublyLinkedList.prototype.rend = function(){
178178
return this.riterator(this.front);
179-
};
179+
}
180180

181181
Iterator.prototype.copy = function() {
182182
return new Iterator(this.front, this.back, this.current);
183-
};
183+
}
184184

185185
ReverseIterator.prototype.copy = function() {
186186
return new ReverseIterator(this.front, this.back, this.current);
187-
};
187+
}
188188

189189
Iterator.prototype.next =
190190
ReverseIterator.prototype.prev = function ( ) {
@@ -193,7 +193,7 @@ ReverseIterator.prototype.prev = function ( ) {
193193

194194
return c === this.back ? { done : true } : { value : c.value , done : false } ;
195195

196-
} ;
196+
}
197197

198198
Iterator.prototype.prev =
199199
ReverseIterator.prototype.next = function ( ) {
@@ -202,12 +202,11 @@ ReverseIterator.prototype.next = function ( ) {
202202

203203
return c === this.front ? { done : true } : { value : c.value , done : false } ;
204204

205-
} ;
205+
}
206206

207207
DoublyLinkedList.prototype[Symbol.iterator] = DoublyLinkedList.prototype.begin ;
208208
DoublyLinkedList.Node = Node;
209209
DoublyLinkedList.Iterator = Iterator;
210210
DoublyLinkedList.ReverseIterator = ReverseIterator;
211211

212212

213-
exports.DoublyLinkedList = DoublyLinkedList;

src/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './DoublyLinkedList' ;

0 commit comments

Comments
 (0)