• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Looking for an appropriate data structure

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Marshal
Posts: 74033
332
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Campbell, that certainly sounds better.
 
Campbell Ritchie
Marshal
Posts: 74033
332
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic