Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想设计一个自动完成功能,而不是在数据库上搜索,我想预先进入缓存并搜索它。在 Java.util 包上执行此操作的最佳数据结构是什么?看起来 LinkedList 很适合它。有人设计过这样的系统吗?
JavaLinkedHashMap和LinkedHashSet类型对于构建缓存非常有用。它们的行为与常规散列容器一样,但如果您愿意,它们支持 LRU 缓存驱逐。这些容器的“链接”部分指的是有一个链接列表穿过它们,所以希望它们是您正在寻找的东西。
LinkedHashMap
LinkedHashSet
希望这可以帮助!