Sync zh and zh-hant versions.
This commit is contained in:
parent
3494e1d2ba
commit
12e31bd47e
@ -72,6 +72,9 @@ func (q *arrayDeque) pushLast(num int) {
|
|||||||
/* 佇列首出列 */
|
/* 佇列首出列 */
|
||||||
func (q *arrayDeque) popFirst() any {
|
func (q *arrayDeque) popFirst() any {
|
||||||
num := q.peekFirst()
|
num := q.peekFirst()
|
||||||
|
if num == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
// 佇列首指標向後移動一位
|
// 佇列首指標向後移動一位
|
||||||
q.front = q.index(q.front + 1)
|
q.front = q.index(q.front + 1)
|
||||||
q.queSize--
|
q.queSize--
|
||||||
@ -81,6 +84,9 @@ func (q *arrayDeque) popFirst() any {
|
|||||||
/* 佇列尾出列 */
|
/* 佇列尾出列 */
|
||||||
func (q *arrayDeque) popLast() any {
|
func (q *arrayDeque) popLast() any {
|
||||||
num := q.peekLast()
|
num := q.peekLast()
|
||||||
|
if num == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
q.queSize--
|
q.queSize--
|
||||||
return num
|
return num
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,10 @@ func (q *arrayQueue) push(num int) {
|
|||||||
/* 出列 */
|
/* 出列 */
|
||||||
func (q *arrayQueue) pop() any {
|
func (q *arrayQueue) pop() any {
|
||||||
num := q.peek()
|
num := q.peek()
|
||||||
|
if num == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// 佇列首指標向後移動一位,若越過尾部,則返回到陣列頭部
|
// 佇列首指標向後移動一位,若越過尾部,則返回到陣列頭部
|
||||||
q.front = (q.front + 1) % q.queCapacity
|
q.front = (q.front + 1) % q.queCapacity
|
||||||
q.queSize--
|
q.queSize--
|
||||||
|
@ -46,9 +46,13 @@ func TestQueue(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestArrayQueue(t *testing.T) {
|
func TestArrayQueue(t *testing.T) {
|
||||||
|
|
||||||
// 初始化佇列,使用佇列的通用介面
|
// 初始化佇列,使用佇列的通用介面
|
||||||
capacity := 10
|
capacity := 10
|
||||||
queue := newArrayQueue(capacity)
|
queue := newArrayQueue(capacity)
|
||||||
|
if queue.pop() != nil {
|
||||||
|
t.Errorf("want:%v,got:%v", nil, queue.pop())
|
||||||
|
}
|
||||||
|
|
||||||
// 元素入列
|
// 元素入列
|
||||||
queue.push(1)
|
queue.push(1)
|
||||||
|
@ -23,7 +23,7 @@ fn backtrack(mut state: Vec<i32>, choices: &[i32], selected: &mut [bool], res: &
|
|||||||
backtrack(state.clone(), choices, selected, res);
|
backtrack(state.clone(), choices, selected, res);
|
||||||
// 回退:撤銷選擇,恢復到之前的狀態
|
// 回退:撤銷選擇,恢復到之前的狀態
|
||||||
selected[i] = false;
|
selected[i] = false;
|
||||||
state.remove(state.len() - 1);
|
state.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ fn backtrack(mut state: Vec<i32>, choices: &[i32], selected: &mut [bool], res: &
|
|||||||
backtrack(state.clone(), choices, selected, res);
|
backtrack(state.clone(), choices, selected, res);
|
||||||
// 回退:撤銷選擇,恢復到之前的狀態
|
// 回退:撤銷選擇,恢復到之前的狀態
|
||||||
selected[i] = false;
|
selected[i] = false;
|
||||||
state.remove(state.len() - 1);
|
state.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -286,6 +286,14 @@
|
|||||||
<br><sub>Zig, Rust</sub>
|
<br><sub>Zig, Rust</sub>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="profile-cell">
|
||||||
|
<a href="https://github.com/curtishd">
|
||||||
|
<img class="profile-img" src="../assets/avatar/avatar_curtishd.jpg"
|
||||||
|
alt="Reviewer: curtishd" />
|
||||||
|
<br><b>curtishd</b>
|
||||||
|
<br><sub>Kotlin</sub>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
<div class="profile-cell">
|
<div class="profile-cell">
|
||||||
<a href="https://github.com/Gonglja">
|
<a href="https://github.com/Gonglja">
|
||||||
<img class="profile-img" src="../assets/avatar/avatar_Gonglja.jpg" alt="Reviewer: Gonglja" />
|
<img class="profile-img" src="../assets/avatar/avatar_Gonglja.jpg" alt="Reviewer: Gonglja" />
|
||||||
|
Loading…
Reference in New Issue
Block a user