MCPcopy Index your code
hub / github.com/careercup/ctci / insertResults

Method insertResults

java/Chapter 10/Question10_7/Cache.java:78–94  ·  view source on GitHub ↗
(String query, String[] results)

Source from the content-addressed store, hash-verified

76 }
77
78 public void insertResults(String query, String[] results) {
79 if (map.containsKey(query)) {
80 Node node = map.get(query);
81 node.results = results;
82 moveToFront(node);
83 return;
84 }
85
86 Node node = new Node(query, results);
87 moveToFront(node);
88 map.put(query, node);
89
90 if (size > MAX_SIZE) {
91 map.remove(tail.query);
92 removeFromLinkedList(tail);
93 }
94 }
95}

Callers 1

mainMethod · 0.95

Calls 5

moveToFrontMethod · 0.95
removeFromLinkedListMethod · 0.95
putMethod · 0.80
getMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected