您将如何实现像 Thunderbird 的“快速搜索”这样的功能?
著名的 Mozilla Thunderbird 电子邮件客户端有一个名为“过滤这些邮件”的搜索栏。它允许用户通过仅显示标题、发件人或收件人包含用户键入的单词的邮件来快速过滤邮件。
鉴于即使在显示大量消息时它也必须尽可能快,您将如何实现这样的功能?应该使用预先计算的索引或类似的数据结构吗?或者只是迭代消息?
The well-known Mozilla Thunderbird email client has a search bar called "filter these messages". It allows the user to quickly filter messages by displaying only those whose title, sender or recipients contain the words that the user types.
How would you implement such a functionality, given that it has to be as fast as possible even when displaying tons of messages? Should one use a precomputed index or similar data structure? Or simply iterate through the messages?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
开源软件的美妙之处在于你可以看到源代码:)。您甚至可以在线查看源代码:
当您查看 Mozilla 的源代码时,请非常小心并表现得很好!如果您违反他们的许可,那将是非常粗鲁的。
我最初会从直接搜索开始,如果性能不足,那么我会尝试找到一种方法来改进它。如果您确实对性能感到紧张,那么也许可以尝试实现一些使用的数据结构由 Google 提供。
The beauty of open source software is that you can see the source :). You can even view the source code online:
Be very careful and play nice when you look at Mozilla's source code! It would be very rude if you violate their licensing.
I would initially start by doing a direct search and if the performance is insufficient, then I'll try to find a way to improve it. If you're really strapped for performance, then maybe try and implementing some of the data structures used by Google.