一对桌子?
我的想法是处理两组重要性大致相同的数据。在我正在处理的项目中,有一些带有关联标签的文件。最初,我只是将数据保存在哈希表中,其中文件作为键,每个文件的标签作为值。但有时我想查看所有标签并了解有关文件的信息。
我决定跟踪两个哈希表,一个正向 (file0->(tag1 tag2):file1->(tag2 tag3))
和一个反向 (tag1->(tag1 tag2):file1->(tag2 tag3))
。 (file0):tag2->(file0 file1):tag3->(file1))。我还没有尝试过,因为我不确定它是否像我想象的那样有用,或者我只是疯了。这有什么好处吗?之前的使用情况?
I had this idea for working with two sets of data that are about equal in importance. In a project I'm working on, there are files with associated tags. Originally I just kept the data in a hash table with the files as keys and each file's tags as value. But there are often times when I want to look at all of the tags and say something about the files.
I decided I could keep track of two hash tables, a forward (file0->(tag1 tag2):file1->(tag2 tag3))
and a reverse (tag1->(file0):tag2->(file0 file1):tag3->(file1))
. I haven't tried it yet, because I'm not sure if it's as useful as I think it might be or I'm just off my head. Is there any advantage to this? Prior usage?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果键和值都是唯一的,那么这将起作用。如果没有,您将需要一个“MultiValueMap” 可以处理每个键的多个条目。
That will work if both keys and values are unique. If not, you will need a "MultiValueMap" that can handle multple entries per key.