mirror of
https://github.com/krahets/hello-algo.git
synced 2026-11-02 11:15:19 +08:00
Retranslate the complete Japanese online edition from Chinese (#2008)
* Retranslate the complete Japanese online edition from Chinese * Fit Japanese homepage labels and localize heading permalinks * Point Japanese contribution instructions to the Japanese preview * Replace locale conditionals with multilingual UI tables
This commit is contained in:
@@ -4,19 +4,19 @@
|
||||
* Author: S-N-O-R-L-A-X ([email protected])
|
||||
*/
|
||||
|
||||
/* 配列ベースのスタック */
|
||||
/* 配列で実装したスタック */
|
||||
class ArrayStack {
|
||||
#stack;
|
||||
constructor() {
|
||||
this.#stack = [];
|
||||
}
|
||||
|
||||
/* スタックの長さを取得 */
|
||||
/* スタックの長さを取得する */
|
||||
get size() {
|
||||
return this.#stack.length;
|
||||
}
|
||||
|
||||
/* スタックが空かどうかを判定 */
|
||||
/* スタックが空かどうかを判定する */
|
||||
isEmpty() {
|
||||
return this.#stack.length === 0;
|
||||
}
|
||||
@@ -28,13 +28,13 @@ class ArrayStack {
|
||||
|
||||
/* ポップ */
|
||||
pop() {
|
||||
if (this.isEmpty()) throw new Error('スタックが空');
|
||||
if (this.isEmpty()) throw new Error('スタックが空です');
|
||||
return this.#stack.pop();
|
||||
}
|
||||
|
||||
/* スタックトップの要素にアクセス */
|
||||
/* スタックの先頭要素にアクセスする */
|
||||
top() {
|
||||
if (this.isEmpty()) throw new Error('スタックが空');
|
||||
if (this.isEmpty()) throw new Error('スタックが空です');
|
||||
return this.#stack[this.#stack.length - 1];
|
||||
}
|
||||
|
||||
@@ -44,11 +44,11 @@ class ArrayStack {
|
||||
}
|
||||
}
|
||||
|
||||
/* Driver Code */
|
||||
/* スタックを初期化 */
|
||||
/* 実行用コード */
|
||||
/* スタックを初期化する */
|
||||
const stack = new ArrayStack();
|
||||
|
||||
/* 要素をプッシュ */
|
||||
/* 要素をプッシュする */
|
||||
stack.push(1);
|
||||
stack.push(3);
|
||||
stack.push(2);
|
||||
@@ -57,19 +57,19 @@ stack.push(4);
|
||||
console.log('スタック stack = ');
|
||||
console.log(stack.toArray());
|
||||
|
||||
/* スタックトップの要素にアクセス */
|
||||
/* スタックの先頭要素にアクセスする */
|
||||
const top = stack.top();
|
||||
console.log('スタックトップ要素 top = ' + top);
|
||||
console.log('スタックの先頭要素 top = ' + top);
|
||||
|
||||
/* 要素をポップ */
|
||||
/* 要素をポップする */
|
||||
const pop = stack.pop();
|
||||
console.log('ポップした要素 pop = ' + pop + ',ポップ後 stack = ');
|
||||
console.log('ポップした要素 pop = ' + pop + '、ポップ後 stack = ');
|
||||
console.log(stack.toArray());
|
||||
|
||||
/* スタックの長さを取得 */
|
||||
/* スタックの長さを取得する */
|
||||
const size = stack.size;
|
||||
console.log('スタックの長さ size = ' + size);
|
||||
|
||||
/* 空かどうかを判定 */
|
||||
/* 空かどうかを判定する */
|
||||
const isEmpty = stack.isEmpty();
|
||||
console.log('スタックは空か = ' + isEmpty);
|
||||
|
||||
Reference in New Issue
Block a user