mirror of
https://github.com/krahets/hello-algo.git
synced 2025-07-06 22:34:18 +08:00
Unify the function naming of
queue from `offer()` to `push()`
This commit is contained in:
@ -41,7 +41,7 @@ namespace hello_algo.chapter_stack_and_queue
|
||||
}
|
||||
|
||||
/* 入队 */
|
||||
public void offer(int num)
|
||||
public void push(int num)
|
||||
{
|
||||
if (queSize == capacity())
|
||||
{
|
||||
@ -97,11 +97,11 @@ namespace hello_algo.chapter_stack_and_queue
|
||||
ArrayQueue queue = new ArrayQueue(capacity);
|
||||
|
||||
/* 元素入队 */
|
||||
queue.offer(1);
|
||||
queue.offer(3);
|
||||
queue.offer(2);
|
||||
queue.offer(5);
|
||||
queue.offer(4);
|
||||
queue.push(1);
|
||||
queue.push(3);
|
||||
queue.push(2);
|
||||
queue.push(5);
|
||||
queue.push(4);
|
||||
Console.WriteLine("队列 queue = " + string.Join(",", queue.toArray()));
|
||||
|
||||
/* 访问队首元素 */
|
||||
@ -123,7 +123,7 @@ namespace hello_algo.chapter_stack_and_queue
|
||||
/* 测试环形数组 */
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
queue.offer(i);
|
||||
queue.push(i);
|
||||
queue.poll();
|
||||
Console.WriteLine("第 " + i + " 轮入队 + 出队后 queue = " + string.Join(",", queue.toArray()));
|
||||
}
|
||||
|
Reference in New Issue
Block a user