連結串列
有點像⽕⻋,⻋廂和⻋廂之間連結,有點是可以隨時替換⻋廂,react最新架構的fifiber,就是從樹變成
了連結串列,能夠讓diffff任務隨時中斷
class node
}class linkedlist
const node = new node(element)
if (this.head === null) else
this.current.next = node
}this.length++
}// 移除指定位置元素
removeat(position) else
this.current = this.head
while (index < position)
previous.next = this.current.next
}this.length--}}
// 在指定位置加⼊元素
insert (position, element) else
previous.next = node // 在⽬標位置插⼊相應元素
node.next = current
}this.length++}}
// 連結串列中是否含有某個元素, 如果有的話返回相應位置, ⽆的話返回 -1
indexof(element)
this.current = this.current.next
index++
}return -1
}// 移除某元素
remove(element)
// 獲取⼤⼩
size ()
// 獲取最開頭的連結串列
gethead ()
// 是否為空
isempty ()
// 列印連結串列元素
log ()
console.log(str)
return str}}
// 測試⽤例
var linkedlist = new linkedlist()
linkedlist.log() // '5 10 15 20'
linkedlist.removeat(1)
linkedlist.log() // '5 15 20'
linkedlist.insert(1, 10)
linkedlist.log()
索引: o(n)
搜尋: o(n)
插⼊: o(1)
移除: o(1)
集合
http隧道的研究
1 reduh為什麼要bind一個udp,如何維持tcp的? 似乎只要不close,就不會關閉開啟過的socket 2 如果web超時,或者指令碼超時,是否意味著會斷開連線。 似乎並不會 3 是否針對可對長連線特性進行優化。 中已經通過urllib3的連線池,進行長連線維持 理論上,可以傳送少量資料精...
openfire的叢集研究
研究了幾個月的openfire的叢集,今天終於有點眉目了。分享一下。 openfire的叢集通過外掛整合到伺服器中。 該外掛使用oracle...
wpf的研究和反思
wpf的研究和反思 目前是否適合使用wpf wpf windows presentation foundation 是微軟推出的基於wind...