Need to Map a Pair-tuple to a Record

Hi all,

I need a data structure or way to insert a triple (A, B, n), where A and B are strings and 'n' is a number, into a data structure. So, the pairs A and B are the keys for a record and when I see a Record that is already in the data structure, I need to increment the 'n' field; else, if it is not a duplicate, I just throw a new Record object into the data structure, where its 'n' field is initialized to some number. Essentially, I'm just reading lines from a text file consisting of several columns of information, but I only care about 3 of the columns. And to reiterate, A and B are strings which serve to indicate a unique Record and 'n' is some number. The classes TreeSet, TreeMap, and Hashtable don't seem to want to work. Please help me. Thank you.

Kindest regards,

SW

[821 byte] By [sean_williams_gsa] at [2007-11-27 11:28:38]
# 1

Why not define an appropriate Key class to hold the pair of strings that you mention, then what you want is a Map < Key, Integer >

BigDaddyLoveHandlesa at 2007-7-29 16:23:17 > top of Java-index,Java Essentials,Java Programming...
# 2

You could even do it with aMap<String, Map<String, Integer>>

although I like BigDaddyLoveHandles' approach better.

dwga at 2007-7-29 16:23:17 > top of Java-index,Java Essentials,Java Programming...
# 3

> You could even do it with aMap<String,

> Map<String, Integer>>

although I like

> BigDaddyLoveHandles' approach better.

Mmmm.... curry...

http://en.wikipedia.org/wiki/Currying

BigDaddyLoveHandlesa at 2007-7-29 16:23:17 > top of Java-index,Java Essentials,Java Programming...