Method
search
(List<Pair<String, Integer>> list, int timestamp)
Source from the content-addressed store, hash-verified
| 18 | } |
| 19 | |
| 20 | public String search(List<Pair<String, Integer>> list, int timestamp) { |
| 21 | int start = 0; |
| 22 | int end = list.size() - 1; |
| 23 | while (start < end) { |
| 24 | int mid = start + (end - start + 1) / 2; |
| 25 | if (list.get(mid).getValue() <= timestamp) start = mid; else end = |
| 26 | mid - 1; |
| 27 | } |
| 28 | return list.get(start).getValue() <= timestamp |
| 29 | ? list.get(start).getKey() |
| 30 | : ""; |
| 31 | } |
| 32 | } |
Tested by
no test coverage detected