WalterBright

Results 2 comments of WalterBright

try Px/PX/pX which will not be transformed

双向链表+Map ```js class LRUCache{ cache=new Map() capacity head={} //head表示最少访问 constructor(capacity){ this.capacity=capacity this.link(this.head,this.head) } link(nodeA,nodeB){ nodeA.next=nodeB nodeB.prev=nodeA } moveToTail(cache_at_key){ //tail表示最近访问 //优化:连续访问时无需操作 if(cache_at_key.next===this.head) return; this.link(cache_at_key.prev,cache_at_key.next) let tail_prev_node=this.head.prev this.link(tail_prev_node,cache_at_key) this.link(cache_at_key,this.head) } get(key){ let...