@@ -25,188 +25,3 @@ for ( let value of list ) ... ;
25
25
[ ![ Code technical debt] ( https://img.shields.io/codeclimate/tech-debt/aureooms/js-dll.svg )] ( https://codeclimate.com/github/aureooms/js-dll/trends/technical_debt )
26
26
[ ![ Documentation] ( https://aureooms.github.io/js-dll//badge.svg )] ( https://aureooms.github.io/js-dll//source.html )
27
27
[ ![ Package size] ( https://img.shields.io/bundlephobia/minzip/@aureooms/js-dll )] ( https://bundlephobia.com/result?p=@aureooms/js-dll )
28
-
29
- Can be managed through [ jspm] ( https://github.com/jspm/jspm-cli ) ,
30
- [ duo] ( https://github.com/duojs/duo ) ,
31
- [ component] ( https://github.com/componentjs/component ) ,
32
- [ bower] ( https://github.com/bower/bower ) ,
33
- [ ender] ( https://github.com/ender-js/Ender ) ,
34
- [ jam] ( https://github.com/caolan/jam ) ,
35
- [ spm] ( https://github.com/spmjs/spm ) ,
36
- and [ npm] ( https://github.com/npm/npm ) .
37
-
38
- ## Install
39
-
40
- ### jspm
41
- ``` terminal
42
- jspm install github:aureooms/js-dll
43
- # or
44
- jspm install npm:@aureooms/js-dll
45
- ```
46
- ### duo
47
- No install step needed for duo!
48
-
49
- ### component
50
- ``` terminal
51
- component install aureooms/js-dll
52
- ```
53
-
54
- ### bower
55
- ``` terminal
56
- bower install @aureooms/js-dll
57
- ```
58
-
59
- ### ender
60
- ``` terminal
61
- ender add @aureooms/js-dll
62
- ```
63
-
64
- ### jam
65
- ``` terminal
66
- jam install @aureooms/js-dll
67
- ```
68
-
69
- ### spm
70
- ``` terminal
71
- spm install @aureooms/js-dll --save
72
- ```
73
-
74
- ### npm
75
- ``` terminal
76
- npm install @aureooms/js-dll --save
77
- ```
78
-
79
- ## Require
80
- ### jspm
81
- ``` js
82
- let dll = require ( " github:aureooms/js-dll" ) ;
83
- // or
84
- import dll from ' @aureooms/js-dll' ;
85
- ```
86
- ### duo
87
- ``` js
88
- let dll = require ( " aureooms/js-dll" ) ;
89
- ```
90
-
91
- ### component, ender, spm, npm
92
- ``` js
93
- let dll = require ( " @aureooms/js-dll" ) ;
94
- ```
95
-
96
- ### bower
97
- The script tag exposes the global variable ` dll ` .
98
- ``` html
99
- <script src =" bower_components/@aureooms/js-dll/js/dist/dll.min.js" ></script >
100
- ```
101
- Alternatively, you can use any tool mentioned [ here] ( http://bower.io/docs/tools/ ) .
102
-
103
- ### jam
104
- ``` js
105
- require ( [ " @aureooms/js-dll" ] , function ( dll ) { ... } ) ;
106
- ```
107
-
108
- ## Use
109
-
110
- ``` js
111
- let List = dll .DoublyLinkedList ;
112
-
113
- let list = new List ( ) ;
114
-
115
- let iterators = [ for ( x of [ 0 , 1 , 2 ] ) list .push ( x ) ] ;
116
-
117
- [ for ( let element of list ) element ] ; // [ 0 , 1 , 2 ]
118
-
119
- list .erase ( iterator[1 ] ) ; // removes `1` from the list
120
-
121
- [ for ( let element of list ) element ] ; // [ 0 , 2 ]
122
-
123
- // note that other iterators remain valid
124
-
125
- iterator[0 ].current .value = 0 ;
126
- iterator[2 ].current .value = 2 ;
127
-
128
- iterator[0 ].next ( ) ; // { value : 2 , done : false }
129
- iterator[0 ].next ( ) ; // { done : true }
130
-
131
- iterator[0 ].prev ( ) ; // { value : 2 , done : false }
132
- iterator[0 ].prev ( ) ; // { value : 0 , done : false }
133
- iterator[0 ].prev ( ) ; // { done : true }
134
-
135
- iterator[2 ].prev ( ) ; // { value : 0 , done : false }
136
- iterator[2 ].prev ( ) ; // { done : true }
137
-
138
- iterator[2 ].next ( ) ; // { value : 0 , done : false }
139
- iterator[2 ].next ( ) ; // { value : 2 , done : false }
140
- iterator[2 ].next ( ) ; // { done : true }
141
-
142
- // SUPPORTED METHODS
143
-
144
- // Constructor
145
- List ; // new ( ) -> List
146
-
147
- // number of elements in the list
148
- list .length ; // integer
149
-
150
- // returns iterator at the beginning of the list
151
- List .prototype [Symbol .iterator ] ; // ( ) -> iterator
152
-
153
- // inserts value after iterator, returns new iterator
154
- List .prototype .insertAfter ; // ( iterator , value ) -> iterator
155
-
156
- // inserts value before iterator, returns new iterator
157
- List .prototype .insertBefore ; // ( iterator , value ) -> iterator
158
-
159
- // inserts value at the beginning of the list, returns new iterator
160
- List .prototype .unshift ; // ( value ) -> iterator
161
-
162
- // inserts value at the end of the list, returns new iterator
163
- List .prototype .push ; // ( value ) -> iterator
164
-
165
- // erases iterator, returns next iterator
166
- List .prototype .erase ; // ( iterator ) -> iterator {next}
167
-
168
- // erases iterator, returns previous iterator
169
- List .prototype .rerase ; // ( iterator ) -> iterator {prev}
170
-
171
- // erases iterators in [first, last[, returns a copy of last
172
- List .prototype .eraserange ; // ( first , last ) -> iterator
173
-
174
- // erases iterator at the beginning of the list, returns associated value
175
- List .prototype .shift ; // ( ) -> value
176
-
177
- // erases iterator at the end of the list, returns associated value
178
- List .prototype .pop ; // ( ) -> value
179
-
180
- // erases the contents of the list
181
- List .prototype .clear ; // ( ) -> self
182
-
183
- // returns iterator at the beginning of the list
184
- List .prototype .begin ; // ( ) -> iterator
185
-
186
- // returns iterator at the end of the list
187
- List .prototype .end ; // ( ) -> iterator
188
-
189
- // returns reverse iterator at the end of the list
190
- List .prototype .rbegin ; // ( ) -> iterator
191
-
192
- // returns reverse iterator at the beginning of the list
193
- List .prototype .rend ; // ( ) -> iterator
194
-
195
- // returns a copy of self
196
- Iterator .prototype .copy ; // ( ) -> iterator
197
-
198
- // returns a copy of self
199
- ReverseIterator .prototype .copy ; // ( ) -> iterator
200
-
201
- // moves iterator one step forward, standard iterator protocol return object
202
- Iterator .prototype .next ; // ( ) -> { done , value }
203
-
204
- // moves iterator one step backward, standard iterator protocol return object
205
- Iterator .prototype .prev ; // ( ) -> { done , value }
206
-
207
- // moves iterator one step forward, standard iterator protocol return object
208
- ReverseIterator .prototype .next ; // ( ) -> { done , value }
209
-
210
- // moves iterator one step backward, standard iterator protocol return object
211
- ReverseIterator .prototype .prev ; // ( ) -> { done , value }
212
- ```
0 commit comments