GeeCON Prague 2014*
The moose likes Java in General and the fly likes Looking for an appropriate data structure Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "Looking for an appropriate data structure" Watch "Looking for an appropriate data structure" New topic
Author

Looking for an appropriate data structure

Edward Nelson
Greenhorn

Joined: Apr 29, 2008
Posts: 8
I need a data structure that can store multiple (ordered) units of data, each of them in the following format:

Value1 is mapped to Value2 which is mapped to Value3 which is mapped to Value4

More specifically,
Value1 can be "a" or "b"
Value2 can be "g" or "u"
Value3 can any string
Value4 can be a string containing one character from 'x', 'y', or 'z', or any combination of these (such as "xy", "xz", etc)


A data structure defined as an ArrayList of Map<String, Map><String, Map><String, String>> should work, but I'm looking for better ideas from you guys.

Any suggestions?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39044
    
  23
You have described a class with 4 fields. You will have to do some sort of validation in its constructor. It will probably have to implement the Comparable interface.
Edward Nelson
Greenhorn

Joined: Apr 29, 2008
Posts: 8
Thanks Campbell, that certainly sounds better.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39044
    
  23
You're welcome
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Looking for an appropriate data structure