Add Dart codes to the documents. (#529)

This commit is contained in:
Yudong Jin
2023-06-02 02:40:26 +08:00
committed by GitHub
parent 041a989d33
commit 025051c81b
38 changed files with 849 additions and 96 deletions

View File

@ -250,6 +250,12 @@
```
=== "Dart"
```dart title="stack.dart"
```
## 栈的实现
为了深入了解栈的运行机制,我们来尝试自己实现一个栈类。
@ -333,6 +339,12 @@
[class]{LinkedListStack}-[func]{}
```
=== "Dart"
```dart title="linkedlist_stack.dart"
[class]{LinkedListStack}-[func]{}
```
### 基于数组的实现
在基于「数组」实现栈时,我们可以将数组的尾部作为栈顶。在这样的设计下,入栈与出栈操作就分别对应在数组尾部添加元素与删除元素,时间复杂度都为 $O(1)$ 。
@ -408,6 +420,12 @@
[class]{ArrayStack}-[func]{}
```
=== "Dart"
```dart title="array_stack.dart"
[class]{ArrayStack}-[func]{}
```
## 两种实现对比
### 支持操作