This commit is contained in:
krahets
2024-03-31 03:53:04 +08:00
parent 87af663929
commit c23e576da4
68 changed files with 2139 additions and 22 deletions

View File

@ -315,6 +315,32 @@ comments: true
=== "Kotlin"
```kotlin title="queue.kt"
/* 初始化队列 */
val queue = LinkedList<Int>()
/* 元素入队 */
queue.offer(1)
queue.offer(3)
queue.offer(2)
queue.offer(5)
queue.offer(4)
/* 访问队首元素 */
val peek = queue.peek()
/* 元素出队 */
val pop = queue.poll()
/* 获取队列的长度 */
val size = queue.size
/* 判断队列是否为空 */
val isEmpty = queue.isEmpty()
```
=== "Ruby"
```ruby title="queue.rb"
```
@ -1196,6 +1222,12 @@ comments: true
}
```
=== "Ruby"
```ruby title="linkedlist_queue.rb"
[class]{LinkedListQueue}-[func]{}
```
=== "Zig"
```zig title="linkedlist_queue.zig"
@ -2176,6 +2208,12 @@ comments: true
}
```
=== "Ruby"
```ruby title="array_queue.rb"
[class]{ArrayQueue}-[func]{}
```
=== "Zig"
```zig title="array_queue.zig"