feat:linked list add new method
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 48/100
- Issue 類型
- 功能
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- javascript
- 領域
- data
研究方向
The issue names no implementation file or test. Locate the linked-list implementation and its existing traversal-related tests, then review how iteration is currently exposed. Done means the linked list supports the proposed iterator and for-of traversal, with behavior verified for populated and empty lists.
由索引模型根據 Issue 內容生成。
描述
traverse linked list is easy but uninteresting. You must add new variable and use while.So why not add a method to return a iterator.Then we can use for of to traverse. eg:
getIterator() {
const _this = this
return {
*[Symbol.iterator]() {
let currentNode = _this.head
if (!currentNode) yield node
while (currentNode) {
yield currentNode.value
currentNode = currentNode.next
}
}
}
}
use
const iter = linkedList.getIterator()
for(const item of iter){
console.log(item)
}
- 主要語言
- JavaScript
- 星號
- 197k
- 分支
- 31k
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
trekhleb/javascript-algorithms 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 76/100
trekhleb/javascript-algorithms#2225 ·
-
BinarySearchTreeNode removing可能已有人在做 @bbonch 於 251 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 72/100
trekhleb/javascript-algorithms#2102 · 1 則留言 ·
-
難度 4/5 3-5 天 新手友好度 45/100
trekhleb/javascript-algorithms#2221 · 4 則留言 ·
-
zh-TW translations missing — should contributors help complete?可能已有人在做 @anees4500 於 342 天前認領。 未關閉
難度 4/5 3-5 天 新手友好度 25/100
trekhleb/javascript-algorithms#2085 · 6 則留言 · 1 個 reaction ·
-
難度 3/5 1-2 天 新手友好度 35/100
trekhleb/javascript-algorithms#2065 · 1 則留言 ·
查看 trekhleb/javascript-algorithms 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 68/100
維護者通常 2 天內回覆
-
難度 2/5 1-3 小時 新手友好度 65/100
bigskysoftware/htmx#4147 ·
維護者通常 5 天內回覆
-
難度 2/5 1-3 小時 新手友好度 62/100
vshymanskyy/StandWithUkraine#316 ·
-
難度 1/5 1 小時以內 新手友好度 90/100
-
bug/1-unconfirmed kind/bug
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆