Efficient data structure for a record consisting of a tuple and its value

I want to store sort of a tuple and a value as an entry. I mean something like this

A B -> 1
A C -> 2
E F -> 3
C D -> 4

The first two values are always unique, in the sense A and B occur only once together. What would be an efficient data structure for the purpose, keeping in mind that I may need to fetch any of the three fields from an entry efficiently ?

If possible, please provide some relevant code !!


A Map would work well. You need to have an object to represent the first two items. Make sure that the hashCode and equals methods are implemented correctly on your new class. Then you can use that class for the key.

Map<MyKeyClass, Integer> map = new HashMap<MyKeyClass, Integer>();
map.put(new MyKeyClass("A", "B"), 1);
map.put(new MyKeyClass("A", "C"), 2);

Need Your Help

GeoJSON Coordinates?

geolocation gis geocoding geo geojson

I have a GeoJSON file that I am trying to process in order to draw some features on top of google maps. The problem, however, is that the coordinates are not in the conventional latitude/longitude

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.