chore(i8n,learn): processed translations

This commit is contained in:
Crowdin Bot
2021-02-06 04:42:36 +00:00
committed by Mrugesh Mohapatra
parent 15047f2d90
commit e5c44a3ae5
3274 changed files with 172122 additions and 14164 deletions

View File

@ -1,18 +1,22 @@
---
id: 587d8250367417b2b2512c5f
title: 创建一个堆栈类
title: Create a Stack Class
challengeType: 1
videoUrl: ''
forumTopicId: 301633
dashedName: create-a-stack-class
---
# --description--
在上一节中,我们讨论了堆栈是什么以及如何使用数组来表示堆栈。在本节中,我们将创建自己的堆栈类。虽然您可以使用数组来创建堆栈,但有时最好限制我们对堆栈的控制量。除了`push``pop`方法之外,堆栈还有其他有用的方法。让我们为我们的堆栈类添加一个`peek` `isEmpty``clear`方法。说明编写一个`push`方法,将元素推送到堆栈顶部,一个`pop`方法删除堆栈顶部的元素,一个`peek`堆栈中第一个元素的`peek`方法,一个`isEmpty`方法用于检查是否存在stack是空的是一个`clear`堆栈中所有元素的方法。通常堆栈没有这个,但我们添加了一个控制台记录集合的`print`助手方法。
In the last section, we talked about what a stack is and how we can use an array to represent a stack. In this section, we will be creating our own stack class. Although you can use arrays to create stacks, sometimes it is best to limit the amount of control we have with our stacks. Apart from the `push` and `pop` method, stacks have other useful methods. Let's add a `peek`, `isEmpty`, and `clear` method to our stack class.
# --instructions--
Write a `push` method that pushes an element to the top of the stack, a `pop` method that removes and returns the element on the top of the stack, a `peek` method that looks at the top element in the stack, an `isEmpty` method that checks if the stack is empty, and a `clear` method that removes all elements from the stack. Normally stacks don't have this, but we've added a `print` helper method that console logs the collection.
# --hints--
你的`Stack`类应该有一个`push`方法。
Your `Stack` class should have a `push` method.
```js
assert(
@ -23,7 +27,7 @@ assert(
);
```
你的`Stack`类应该有一个`pop`方法。
Your `Stack` class should have a `pop` method.
```js
assert(
@ -34,7 +38,7 @@ assert(
);
```
你的`Stack`类应该有一个`peek`方法。
Your `Stack` class should have a `peek` method.
```js
assert(
@ -45,7 +49,7 @@ assert(
);
```
您的`Stack`类应该有一个`isEmpty`方法。
Your `Stack` class should have a `isEmpty` method.
```js
assert(
@ -56,7 +60,7 @@ assert(
);
```
你的`Stack`类应该有一个`clear`方法。
Your `Stack` class should have a `clear` method.
```js
assert(
@ -67,7 +71,7 @@ assert(
);
```
`peek`方法应该返回堆栈的顶部元素
The `peek` method should return the top element of the stack
```js
assert(
@ -79,7 +83,7 @@ assert(
);
```
`pop`方法应该删除并返回堆栈的顶部元素
The `pop` method should remove and return the top element of the stack
```js
assert(
@ -91,7 +95,7 @@ assert(
);
```
如果堆栈不包含任何元素,则`isEmpty`方法应返回true
The `isEmpty` method should return true if a stack does not contain any elements
```js
assert(
@ -102,7 +106,7 @@ assert(
);
```
`clear`方法应该从堆栈中删除所有元素
The `clear` method should remove all element from the stack
```js
assert(