1. 应用场景
按天统计的逻辑利用hashmap进行存储,另外一篇文章已经提到。现在的问题是查询的交易记录表,如果当天没有交易记录,流量余额就是0,这个是不对的,应该是最近一笔交易记录时的流量余额。
1.必须有序
2.能够查询最近的一个key
此时hashmap不能满足要求,试试treemap,map有序的首选。查询了一下api,竟然支持,我利用的是lowerKey方法
Map.Entry<K,V> |
firstEntry()
Returns a key-value mapping associated with the least key in this map, or
null if the map is empty.
|
K |
firstKey()
Returns the first (lowest) key currently in this map.
|
Map.Entry<K,V> |
|