Many bug fixes and improvements (#1270)

* Add Ruby and Kotlin icons
Add the avatar of @curtishd

* Update README

* Synchronize zh-hant and zh versions.

* Translate the pythontutor blocks to traditional Chinese

* Fix en/mkdocs.yml

* Update the landing page of the en version.

* Fix the Dockerfile

* Refine the en landingpage

* Fix en landing page

* Reset the README.md
This commit is contained in:
Yudong Jin
2024-04-11 20:18:19 +08:00
committed by GitHub
parent 07977184ad
commit b2f0d4603d
192 changed files with 2382 additions and 1196 deletions

View File

@ -0,0 +1,38 @@
=begin
File: queue.rb
Created Time: 2024-04-06
Author: Xuan Khoa Tu Nguyen (ngxktuzkai2000@gmail.com)
=end
### Driver Code ###
if __FILE__ == $0
# 初始化佇列
# Ruby 內建的佇列Thread::Queue) 沒有 peek 和走訪方法,可以把 Array 當作佇列來使用
queue = []
# 元素入列
queue.push(1)
queue.push(3)
queue.push(2)
queue.push(5)
queue.push(4)
puts "佇列 queue = #{queue}"
# 訪問佇列元素
peek = queue.first
puts "佇列首元素 peek = #{peek}"
# 元素出列
# 清注意由於是陣列Array#shift 方法時間複雜度為 O(n)
pop = queue.shift
puts "出列元素 pop = #{pop}"
puts "出列後 queue = #{queue}"
# 獲取佇列的長度
size = queue.length
puts "佇列長度 size = #{size}"
# 判斷佇列是否為空
is_empty = queue.empty?
puts "佇列是否為空 = #{is_empty}"
end