Code Comments
Programming Forum and web based access to our favorite programming groups.Oliver Wong wrote: Hey I have looked at rudimentaries - I knew Map = Dictionary :-) Now I understand your 'Pairs' concept, your examples of 'doubles', 'triples' etc., that would work in the M/F dictionary class; and the J4 proposed KeyedCollection. Mind you - if you think about it, the most logical thing is to have names/descriptors as Dictionary Keys. I can't see you get much mileage asking a dictionary "Do you have an element with a Key '12345' ? There are several methods which pick up on the data, but I have never used them. One possibility - use a callback/iterator against the whole collection automatically checking each element. Then terminate with 'quitIteration', when you have found what you want. My prime interest was converting data files written in RM/COBOL to either M/F Files or SQL Tables. As part of 'normalization' I wanted to get rid of duplicate descriptors stored in 700 data sets, (very small volumes each, 20 - 30 entries). Example : Gas Plant A - System 123 - Gas Scrubber Gas Plant B - System 456 - Gas Scrubber Using mnemonic codes in the DB Table, GS = Gas Scrubber - build Dictionary from existing codes in the DB Table and as I read in each RM entry do a look-up : (1) If found use new "GS" code, or (2) add a new code to the Dictionary and write it to the DB Table - the M/F files/Tables written for Plants A and B above contain the new mnemonics. TOP POST - no more Jimmy > > "James J. Gavan" <jgavandeletethis@shaw.ca> wrote in message > news:uJNPf.128728$B94.114109@pd7tw3no... > > > > Yes, I meant something different. > > In Java as well, you can't have a dictionary (though it's called a > "Map" in Java) where two objects have the same key. I was saying you > could "fake" it by having a "Pair" object whose sole purpose is to > contain references to the two objects you *do* want to store. > > Key --> Data > 123 (Hot, Cold) > 124 (push, pull) > 125 (stop, go) > etc. > > The idea is that only one object, the "pair" object, is associate with a > given key. But the pair object is like a collection whose size is > guaranteed to always be 2. Obviously, you can extend this idea if you > wanted to simulate 3 objects per key: > > Key --> Data > 123 (Hot, Warm, Cold) > 124 (push, rest, pull) > 125 (red, green, blue) > etc. > > - Oliver
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.