类似 Gmail 的标签系统
我正在研究多种方法来实施类似于 Gmail 中的标签系统。基本上我有一个最低级别的资源,我想以标签的形式为该资源提供许多组织分组。如果有人实施过类似的事情,我想听听您的意见。我的想法是在 Resource 实例中有一个 List
。我需要有一个有效的机制,以便根据标签或资源进行非常快速的搜索。
谢谢 季米特里斯
I am looking into a number of ways to implement a labelling system similar to the one in Gmail. Basically I have a Resource at the lowest level and I would like to provide a number of organisational groupings for that resource in the form of labels. If anyone has implemented something like that I would like to hear your views. My idea is to have within the Resource instance a List<Label>
. I need to have an efficient mechanism in order to do very fast searches based on the labels or based on the resources.
Thanks
Dimitris
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,我不会那样做。我会考虑维护两个字典,
Label -> HashSet
和Resource -> HashSet<标签>
。这将使您能够在两个方向上快速查找。显然你应该封装它。另外,无论您做什么,都不应该将其嵌入到您的
资源
中。它是一种资源,并且正在维护其标签?不。单一责任等等。Nope, I wouldn't do that. I'd think about maintaining two dictionaries,
Label -> HashSet<Resource>
andResource -> HashSet<Label>
. This will give you fast lookup in both directions. Obviously you should encapsulate this.Also, whatever you do, you shouldn't embed it in your
Resource
. It's a resource, and it's maintaining its labels? No. Single responsibility and all that.