需要快速设计方法

时间:2017-07-03 07:13:33

标签: data-structures hashmap

我正在阅读一个包含orderTime(DateTime对象)& orderID(String)。我可以使用哪种数据结构以及如何 - 如果给定时间范围,我可以将所有订单ID作为该时间范围的一部分给出?

2 个答案:

答案 0 :(得分:0)

您可以使用线性或非线性数据结构。线性数据结构可以与具有基于时间线的排序顺序的顺序Id的链表一样简单。 你也可以去Calender-Queue' s。它们在范围之间查询非常有效。

答案 1 :(得分:0)

您可以使用某种binary search tree,这样您不仅可以快速找到某个键​​的相应值,还可以快速查找树的所有部分大于或小于该键。

例如,在Java中,您可以使用TreeMap,尤其是proxy .post('/Authenticate/user') .forward('http://192.168.1.200:8081/v1/') .use(function (req, res, next) { if (req.params.name === 'admin') { // Overwrite the target URL only for this user console.log('Intercepted log'); // manipulate res here } next(); }); headMapsubMap方法。用法示例:

tailMap