ログ

見る価値ありません

JavaScript

TypeScript/JavaScriptで永続赤黒木

バグってたら教えて下さい 乱数挿入したこの永続赤黒木をgraphvizで視覚化 JavaScriptはGitHubに github.com ライセンス CC0-1.0 type Color = 'red' | 'black'; type Pair<T, S> = { readonly key: T, readonly value: S, }; const Pair = { from<T, S>(key: T, value: </t,></t,>…

JavaScriptで優先度付きキュー(二分ヒープ)

class PriorityQueue { constructor(comp) { this.heap = []; this.compare = comp; } isEmpty() { return this.heap.length == 0; } push(x) { this._upHeap(this.heap.push(x) - 1); } pop() { if(this.isEmpty()) { return undefined; } this._heapSwap(0…

JavaScriptで償却定数時間キュー

class Queue { constructor() { this.front = []; this.back = []; } isEmpty() { return this.front.length == 0 && this.back.length == 0; } push(x) { this.back.push(x); } pop() { if(this.isEmpty()) { return undefined; } if(this.front.length == …

ニコニコ動画の動画本体のページを開くブックマークレットを書いた

javascript知らないけど書いた github.com ハマりポイント & メモ apiに動画IDを投げると記号がパーセントエンコードされた状態のURLが帰ってくるが、jsのglobalThis#decodeURIだとascii文字はデコードしてくれないので、自分で実装する必要がある。 ブック…