地图数据结构图 [英] Map of Maps data structure

查看:125
本文介绍了地图数据结构图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MultiValueMap 课程(Apache公共集合)可以轻松地使用值为Collections的Map。我正在寻找一个类,使其易于使用地图,其键是对象和值是地图。

The MultiValueMap class (Apache commons collections) makes it easy to work with a Map whose values are Collections. I'm looking for a a class that makes it easy to work with a Map whose keys are objects and values are Maps.

我使用的是Java 1.4,所以可以'使用Google Collections或泛型。

I'm using Java 1.4, so can't use Google Collections or generics.

推荐答案

地图映射实际上是一个没有单个根节点的树型结构(以及地图的地图...)。

Map of maps is actually a tree-type structure without single root node (as well as map of maps of maps...).

你可以看看复合图案,被广泛用于实现树结构(如果它们的组件具有相同的类型,这不是我想象的那样)。

You can look at Composite pattern which is widely used for implementing tree structures (if their components has the same type which is not the case as I feel).

另一个解决方案是实现一个简单的域模型。阅读并且易于维护的东西将会更加清晰:

Another solution is to implement a simple domain model. It'll be much clearer to read and easy to maintain something like:

school.getPupil ("John Doe").getMark ("Math")

school.get ("John Doe").get ("Math")

这篇关于地图数据结构图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆