@@ -84,8 +84,8 @@ private class Node {
8484 private int capacity ;
8585 private int count ;
8686 private DoublyLinkedListPlusHashMapSolution .Node head , tail ;
87- private Map <Integer , DoublyLinkedListPlusHashMapSolution .Node > map ;// ATTN: the value should be Node type! This is the whole point
88- // of having a class called Node!
87+ private Map <Integer , DoublyLinkedListPlusHashMapSolution .Node > map ;
88+ // ATTN: the value should be Node type! This is the whole point of having a class called Node!
8989
9090 public DoublyLinkedListPlusHashMapSolution (int capacity ) {
9191 this .capacity = capacity ;
@@ -99,8 +99,8 @@ public DoublyLinkedListPlusHashMapSolution(int capacity) {
9999 }
100100
101101 public int get (int key ) {
102- DoublyLinkedListPlusHashMapSolution .Node node = map .get (key );// HashMap allows value to be null, this is superior than
103- // HashTable!
102+ DoublyLinkedListPlusHashMapSolution .Node node = map .get (key );
103+ // HashMap allows value to be null, this is superior than HashTable!
104104 if (node == null ) {
105105 return -1 ;
106106 } else {
@@ -118,9 +118,9 @@ public void set(int key, int value) {
118118 count ++;
119119
120120 if (count > capacity ) {
121- // ATTN: It's tail.prev, not tail, because tail is always an invalid node, it
122- // doesn't contain anything, it's always the tail.prev that is the last node in the
123- // cache
121+ /** ATTN: It's tail.prev, not tail, because tail is always an invalid node, it
122+ doesn't contain anything, it's always the tail.prev that is the last node in the
123+ cache*/
124124 DoublyLinkedListPlusHashMapSolution .Node toDelete = tail .prev ;
125125 map .remove (toDelete .key );
126126 remove (toDelete );
@@ -134,10 +134,9 @@ public void set(int key, int value) {
134134 }
135135
136136 private void update (DoublyLinkedListPlusHashMapSolution .Node node ) {
137- // this simplifies the process, just do two operations, remove the old node first, and then
138- // just add the node again
139- // this will guarantee that this node will be at the latest position: the most recently used
140- // position.
137+ /** this simplifies the process, just do two operations, remove the old node first, and then
138+ just add the node again this will guarantee that this node will be at the latest position:
139+ the most recently used position.*/
141140 remove (node );
142141 add (node );
143142 }
@@ -148,8 +147,8 @@ private void remove(DoublyLinkedListPlusHashMapSolution.Node node) {
148147 next .prev = prev ;
149148 }
150149
151- private void add (DoublyLinkedListPlusHashMapSolution .Node node ) {// ATTN: we'll always add the node into the first position:
152- // head.next!!!!
150+ private void add (DoublyLinkedListPlusHashMapSolution .Node node ) {
151+ // ATTN: we'll always add the node into the first position: head.next!!!!
153152 DoublyLinkedListPlusHashMapSolution .Node next = head .next ;
154153 head .next = node ;
155154 node .next = next ;
0 commit comments