mirror of
https://github.com/krahets/hello-algo.git
synced 2026-06-18 09:47:56 +08:00
Re-translate the Japanese version (#1871)
* Retranslate Japanese docs with GPT-5.4 * Retranslate Japanese code with GPT-5.4
This commit is contained in:
35
ja/codes/dart/chapter_stack_and_queue/stack.dart
Normal file
35
ja/codes/dart/chapter_stack_and_queue/stack.dart
Normal file
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* File: stack.dart
|
||||
* Created Time: 2023-03-27
|
||||
* Author: liuyuxin (gvenusleo@gmail.com)
|
||||
*/
|
||||
|
||||
void main() {
|
||||
/* スタックを初期化 */
|
||||
// Dart には組み込みのスタッククラスがないため、List をスタックとして使える
|
||||
final List<int> stack = [];
|
||||
|
||||
/* 要素をプッシュ */
|
||||
stack.add(1);
|
||||
stack.add(3);
|
||||
stack.add(2);
|
||||
stack.add(5);
|
||||
stack.add(4);
|
||||
print("スタック stack = $stack");
|
||||
|
||||
/* スタックトップの要素にアクセス */
|
||||
final int peek = stack.last;
|
||||
print("スタックトップの要素 peek = $peek");
|
||||
|
||||
/* 要素をポップ */
|
||||
final int pop = stack.removeLast();
|
||||
print("ポップした要素 pop = $pop ,ポップ後の stack = $stack");
|
||||
|
||||
/* スタックの長さを取得 */
|
||||
final int size = stack.length;
|
||||
print("スタックの長さ size = $size");
|
||||
|
||||
/* 空かどうかを判定 */
|
||||
final bool isEmpty = stack.isEmpty;
|
||||
print("スタックが空かどうか = $isEmpty");
|
||||
}
|
||||
Reference in New Issue
Block a user