File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change 57
57
58
58
``` js
59
59
// 栈结构的封装
60
- class Stack {
60
+ class Map {
61
61
62
62
constructor () {
63
63
this .items = [];
@@ -132,8 +132,8 @@ console.log(stack.toString()); //--> 1 2
132
132
133
133
``` js
134
134
function dec2bin (dec ) {
135
- // new 一个 Stack ,保存余数
136
- const stack = new Stack ();
135
+ // new 一个 Map ,保存余数
136
+ const stack = new Map ();
137
137
138
138
// 当不确定循环次数时,使用 while 循环
139
139
while (dec > 0 ) {
Original file line number Diff line number Diff line change 36
36
37
37
- ` enqueue(element) ` 向队列尾部添加一个(或多个)新的项。
38
38
- ` dequeue() ` 移除队列的第一(即排在队列最前面的)项,并返回被移除的元素。
39
- - ` front() ` 返回队列中的第一个元素——最先被添加,也将是最先被移除的元素。队列不做任何变动(不移除元素,只返回元素信息与 Stack 类的 peek 方法非常类似)。
39
+ - ` front() ` 返回队列中的第一个元素——最先被添加,也将是最先被移除的元素。队列不做任何变动(不移除元素,只返回元素信息与 Map 类的 peek 方法非常类似)。
40
40
- ` isEmpty() ` 如果队列中不包含任何元素,返回 true,否则返回 false。
41
41
- ` size() ` 返回队列包含的元素个数,与数组的 length 属性类似。
42
42
- ` toString() ` 将队列中的内容,转成字符串形式。
You can’t perform that action at this time.
0 commit comments