Hashmap within a Hashmap?  Or better solution?

I might be approaching this all wrong, but I think I want to have a group of nested hashmaps. I'm trying to build an auction house. When someone comes with a new product category, I want create a hashtable for that product category so hashmap allows me to label the category and put in the product as object. then, i want another level of hashtable to map individual product with the bids it receives ($ amounts). and, finally, i want to be able to label each bid by an id token, so, if the bidder comes back, i can then cancel or amend their bid. I was thinking of using an ArrayList to contain the bids for two reasons: (1) I want to order the bids so that I can respond to them on a first come first served basis and (2) I figured I could just keep track of the bid's price and search through the ArrayList for the id to modify it.
I know the following won't work, but am I anywhere close? And, also, how do I deal with determining whether a product category hash has already been created (or a bid price hash) or whether i need to instantiate one? Thanks so much in advance!!!
     private static Map<String, Map<Double, ArrayList<String>>> productCategory;
     private static Map<Double, ArrayList<String>> bids; // double used for the bids and array list of strings is for the id tokens
     public static void main (String[] args) {
          productCategory = new HashMap<String, HashMap <Double, ArrayList<String>>>;
          bids = new HashMap<Double, ArrayList<String>>;

Hmmm... I suppose you could use hashmaps to "map" these relationships, but that doesn't make it a good idea.
There is no need to use a "dynamic" datastructure like a Map to define the relationships you describe. Nesting Maps allows you to model a "tree" of arbitrary depth and complexity (like a file-system directory tree), but in this case "the complete set of allowable relationships between types" is know up-front... note that's between types, not individual instances... so this is a classical "static model" which (funnily enough) should be modeled "statically".
SO... I'd be inclined to model all these relationships as has-a relationships, using simple attribute fields (some of which will be lists).... atleast for the first cut.... later you might decide that there really are subtypes of things (like FloorBid, PhoneBid, or OnlineBid) and you would "refine" the model at that stage.
SO.... I guess I'd start with: An Auction has a Product and a list of Bids. You add a Product to the list, then create an Auction on that product, advertise, and hopefully recieve some Bids. At the completion of the auction some moneyis exchanged for the goods... and the Product, its Auction, and it's bids are either deleted; or (more likely) archived off to a warehouse of historical auction records.
HashMaps are for when you don't/can't know ALL the type-relationships upfront. What you where thinking of doing constitutes abuse (that's too strong a term, but can't think of "the right word") of there dynamic modeling ability.
My advise is "get something down". Getting a "first draft" down is the hard bit... it's the bit where even seasoned IT pro's sometimes suffer "writers block".
HTH.
Cheers. Keith.
Edited by: corlettk on 20/09/2009 13:37 ~~ Clearer.

Similar Messages

  • Third party PO Process -Looking for better solutions

    what would be best solution for the below business process
    We have one corporate headquarters(A) which has 3 plants(Plants X,Y and Z).
    Corp.HQ (A) deals negotiation with one supplier directly and buys the materials and responsible for the payment.
    but the goods should be directly delivered to the plants ...not to Corp.HQ
    At the same time the receiving plants,intern have to pay to the corp.HQ for the same.
    I can think of 2 step process for this process
    Step 1 : Creating Third party PO between Corp.HQ and Supplier
    Step 2 : Creating a Stock transport order /Intercomp order between Corp.HQ and receiving plants
    But is there any solution with Single step or any other better solution for this process?
    Thanks in advance
    Thanks and Regards,
    Kesavan

    The first step is not ok in my opinion, since the goods will be posted for consumption, so there will be no stock to be transferred via the intercompany STO (2nd step in your process).
    In SAP it is possible to use central purchasing organisation. What if the HQ would be represented in the purchasing process as a central purch. org. and it would issue a "normal" PO to the vendor (one PO: vendor --> manufacturing plant)?
    In this case you should solve the payment process only (HQ --> vendor; plant --> HQ) - if the HQ would be set as invoicing party in the PO, the payment between HQ and plant would be solved. In the vendor's SO the HQ should be set as payer/invoicing address, the HQ would receive the invoice and eneter it w/o any PO (but enter the real PO number as reference).
    You would need some development to integrate the two incoming invoices not to have discrepancy.
    Just an idea...

  • I want better solution for adjusting the Material stock values for the last

    my Customer  need to adjust( Decrease)  the closing stock values for the following materials / plant wise as on 31.03.2006 for meeting statuary compliance.
    Material1 :  RS: 4149599    QTY : 10181.03 Ltrs
    Material 2  : RS: 1318596     QTY:  2152.76   Ltrs
    As per my knowledge MM posting periods can open current month and Previous month only. For the reason I proposed the solution as follows:
    Step 1 : post FI Journal Entry on 31.03.2006
    Opening Balance G/L  Account Dr 4149599 + 1318596
    Closting Stock a/c                      Cr 4149599 + 1318596
    Step 2.
    Change the Material Price in MM through T.Code: MR21
    ( Posting will be allowed in current or previous months)
    This makes our CO reports accurate.
    Please  suggest the better solution if it is possible in MM for adjusting the Material stock values for the last financial year.
    WIth Best Regards,
    Rajesh
    <b></b>

    Hi Madhavan,
    Unfortunately this forum deals with migrations from non-Oracle
    environments to Oracle. You seem to be dealing with migrations in
    an Oracle environment mainly.
    I would recommend that you contact Oracle Applications and RDBMS
    support directly. They will have the most up to date
    information/advice on performing these actions.
    Regards
    John
    Madhavan (guest) wrote:
    : Hi John
    : Thanks for your reply.
    : Actually I am planning to upgrade the system.
    : 1. I Want to Upgrade Oracle Financials release 10.7 to the
    : latest version (11.x)
    : 2. Oracle 7 database to oracle 8 or 8i.
    : 3. Oracle is running on NT service pack 3. Do I need to upgrade
    : this?. If not what is the impact on Windows NT?
    : 4. Is the majority still running smart client 10.7 and database
    : 7?
    : 5. What is the necessary time to implement these upgrades? What
    : type of consulting I need to have?
    : 6. I have some employees working on it? Will these changes
    : affect them?
    : What type of precautions I need to take on the whole??
    : Thank You
    : Madhavan
    Oracle Technology Network
    http://technet.oracle.com
    null

  • Better solution than PARAM reset to keep Thunderbolt Port properly working.

    I have a MBP 17" (late 2011),
    To its Thunderbolt Port I have connected my Samsung T260 Display alternately with a KANEX 'Thunderbolt to eSATA/USB3.0' Adapter.
    But this always needs a PARAM reset after having the Display intermediately connected, else the ANKER 7xUSB3.0 Hub connected to the KANEX Adapter wouldn't be recognized correctly.
    Is there a better solution available for selective resetting the Thunderbolt Port, without restarting the system?
    Many Thanks for support.

    Update: I obtained a new replacement MiniDisplayPort-to-HDMI cable, and both displays are working fine now. However — and this is what's weird — the fix was not completely immediate! At first, all the resolution modes (including 1080p) began working again, but I was still seeing ghost images of moved or closed windows on the screen! After a day or so, those went away. What could possibly explain the temporary persistence of the ghost images even with a new cable?

  • Better solution for scaling of value

    Hi,
    We have a requirement of scaling the values retrieved in reports, We had two solutions,
    1) Use EvGTS function to scale vale
    2) Use Excel functionality to scale the value
    Please let us know which is a better solution.
    Thanks & Regards,
    Ramanathan

    Hi Ramanathan,
    You can use EvGTS function, because it retrieves the data and also scales the values.
    Regards,
    Raghu

  • Need better solution than FCPX for audio cleaning

    Hi, I have a track for a wedding with a lot of background noise. The settings to improve audio on FCPX are not helping much. What's the bets solution to improve voice and reduce background noise?
    Thanks

    If Audacity or STP don't handle it for you, seriously consider giving ScreenFlow a try. ScreenFlow has about the best noise reduction I've ever heard from any app I've ever used. You can load the audio (or video+audio) up in SF (create a New Document from the File menu), drag and drop your media into the Media panel, then drag it to the timeline; select the audio track, go to the audio panel (speaker icon) and select: Filter: Remove Background Noise (accept the default setting of 80%) -- that's usually all there is to it!  There's a free trial available (http://www.telestream.net/screenflow/overview.htm) — it's fully functional except that it watermarks the video output. It will export AIFF audio (LinearPCM 48kHz) and you can export audio only.

  • Old table style that i'm surprised Indesign doesnt have a better solution for

    Hey guys, I had a question about indesign tables. In one publication I am working in, the client has expressed a desire for table to be done the way they always did them which is the following.
    When the table is first being introduced to the reader (that is when it starts) it has a .75 stroke above. however if the header row occurs on any succeding pages, then that stroke should be .25 like any other strokes that may occur on the table (like at the bottom, or the line under the headers.
    This is so simple but right now it has me stumped. Is there any way to do this in an easier fashion than having to convert the header to a body row recreate or fake the header row by putting it into the regular flow of rows? Thanks all!

    Yeah, that's what I'm saying: you can't just apply a stroke to the top of a frame, and if your objects aren't anchored then you risk the possibility of a number of lines randomly floating around. The whole point of anchored objects is to anchor them to a particular point in the text, so when they text reflows they follow along. So: use the pen tool to draw your line, copy it to your clipboard, create an anchored object, manipulate it until it's sitting exactly where you want it, and paste your new rule in.
    Positioning anchored objects precisely works well once you understand the interface, but the first time out I found it really confusing, hence my link to the help file entry on anchored objects.
    There may well be a better solution for your issue, but this duct tape is what came immediately to mind.

  • String parsing - better solution needed :-(

    Hi Folks,
    Basically I will be taking in a string that represents the name of the output file the user wants, this will be specified in an xml file. The issue I have is that it needs to have non-static elements as part of the name as well (like a timestamp). This can come from two places: 1) the applications map 2)Predefined list of functions. Anything that will be comng from the map will have square brackets around it [], whilst anything the refers to a function will be inside curly brackets {}.
    So I may get a string in the form: filename_[user.id]_{datestamp}.pdf
    This should be output in a file called: filename_12345_2811208.pdf
    My issue is with evaluating the string, to determine what needs to be left as is, replaced with a value from a function, or replaced with a value from the map. I have looked at tokenizing the string and using indexof, but these are more trouble than they are worth. My current solution is, to have 4 booleans- one representing an open and close bracket of each type. When two matching booleans are true (i.e. detected an open and closed square bracket) take the sub-string between the brackets (to do this I use two ints representing the index of the brackets), evaluate it and append it to the output string.
    I have tested this and it works- but I was wondering if there is some other method that works better, as quite frankly my solution is the sort of embarassing crud you would see from a first year student programmer. Any help at all would be massively appreciated.
    Cheers,
    Max

    Hi swmtgoet_x,
    Thanks for the speedy reply- and your understanding of the problem is spot on.
    I had looked at the replace method- the only issue with that is that I have no way of knowing which value the users will want from the map (depending on how they have it implemented there could be hundreds of things in there), so to search the string for any value in the map would be hugely ineffecient :-(
    But having said that- I could look at using that approach for "pre-defined function"- I don't think there will be many of these, but in typical fashion no one has seen fit to gove me a list yet.....so I get to guess. :-s

  • Want better Solution for Migration?

    Hi I am Madhavan
    I Need some guidelines to have a better migration solution.
    We have oracle financials running on Windows NT platform. For
    application side we are using smart client and oracle 7 as the
    database. How to upgrade and migrate the entire system ,keeping
    cost in mind.
    Thank You
    Madhavan.S
    null

    Hi Madhavan,
    Unfortunately this forum deals with migrations from non-Oracle
    environments to Oracle. You seem to be dealing with migrations in
    an Oracle environment mainly.
    I would recommend that you contact Oracle Applications and RDBMS
    support directly. They will have the most up to date
    information/advice on performing these actions.
    Regards
    John
    Madhavan (guest) wrote:
    : Hi John
    : Thanks for your reply.
    : Actually I am planning to upgrade the system.
    : 1. I Want to Upgrade Oracle Financials release 10.7 to the
    : latest version (11.x)
    : 2. Oracle 7 database to oracle 8 or 8i.
    : 3. Oracle is running on NT service pack 3. Do I need to upgrade
    : this?. If not what is the impact on Windows NT?
    : 4. Is the majority still running smart client 10.7 and database
    : 7?
    : 5. What is the necessary time to implement these upgrades? What
    : type of consulting I need to have?
    : 6. I have some employees working on it? Will these changes
    : affect them?
    : What type of precautions I need to take on the whole??
    : Thank You
    : Madhavan
    Oracle Technology Network
    http://technet.oracle.com
    null

  • Any better solution for this ?

    public static void main (String args [])
         for (int row = 1; row <= 5; row++)
              for (int col1 = 4; col1 >= row; col1--)
                   System.out.print(" ");
              for (int col2 = row*2; col2 > 1; col2--)
                   System.out.print("*");
              System.out.println();
         for (int row = 1; row <= 4; row++)
              for (int col1 = 1; col1 <= row; col1++)
                   System.out.print(" ");
              for (int col2 = 4; col2 >= row; col2--)
                   System.out.print("*");
              for (int col3 = row; col3 < 4; col3++)
                   System.out.print("*");
              System.out.println();
    }I'm trying to make this:
    I think that my solution is too long. any shorter solution?
    TQ

    It IS hardwired to produce that figure and only that figure.
    What if they asked you to redo it with fewer or more rows of stars?
    You did a "bad" thing: you hardwired your loop sizes. Something like "i <= 4" is called a "magic number", because someone reading your code would have no idea where the 4 came from.
    You also have 4 appear in several places. That violates the Don't Repeat Yourself rule. If you have to change it, and forget one of the spots, your code is wrong.
    You can help both situations by defining a well-named constant and using that for the loop upper limit:
    public class DiamondsAreAGirlsBestFriend
       public static final int DIAMOND_SIZE = 4;
       public static void main(String [] args)
          for (int row = 0; row <= DIAMOND_SIZE; ++row)
          // and so on
    }Also, better to put this into a method that would take in a diamond size value and return a String. Then it's general.
    None of this is very important for this trivial problem, but they might be worth remembering when you start writing more complex programs.
    %

  • TCP data server or better solution?

    Hi all,
    We upgraded our software system from 32 bit to 64 bit then LabVIEW is also upgraded from LabVIEW 2010 x86 to LabVIEW 2010 x64. However, one device of us does not have the 64 bit driver thus in order to make all the devices works seamlessly in one computer as before, I used TCP data server and client. The server and the main VI are set up on the LabVIEW x64 whereas the client, which drives one device with 32 bit driver, is running on the LabVIEW x86 process on the same computer. I used the Simple Data Server and Simple Data Client in Examples of LabVIEW.
    Would you please advise me or give me some suggestions for the following questions:
    1. By using this configuration, I can only transfer data in one way. If I want to transfer data in both directions, what should I do? Could you please give me some example codes?
    2. I do not understand clearly the synchronization of the server and the client in this case. For example, when I change the waiting time of server and client, sometimes it freezes the program, sometimes it does not work. Could you advise me the perfect way to set the synchronization (as fast as possible).
    3. Is there any possible solution that could be better than this data server/client approach for my 32 bit driver related problem as described above?
    Thank you very much, I appreciate your help.
    Trung

    Could you guys plesae give me some answers/suggestions. 
    I appreciate it.
    Regards,
    Trung

  • Looking for a better solution to the "Save for web" color shift issue

    Ok, everyone who has fussed much with photoshop and "Save For Web" knows about the color shift issue. If you want your colors to look right after you "save for web", you have to work in the sRGB colorspace, and have Proof Colors checked (soft proofing on) and the proof color setup set to Monitor RGB, otherwise what you get looks terrible when displayed in a browser.
    But of course if you are editing for print, this is exactly what you DON'T want to do. Well, I work in both. In fact, often the same images, and I want them to appear as close as reasonably possible in both print and web formats, and without a lot of fussing on my part. And I'm pickiest about the print mode, since I have the most control there, so that's the way I want to edit by default.
    Nothing new here.
    Now comes the interesting part (in my mind, anyway). Obviously there is a known remapping -- because PhotoShop DOES it when you select Proof Colors. So the inverse mapping must also be known (with some gamut issues, but I'm not concerned with those, because, after all, I'm VIEWING it on a monitor anyway!). What I want is a plug-in that automatically applies that inverse mapping so that, when I do a Save For Web, I end up with the colors I've been viewing all the time when setting the shot up in print mode. Then, too, I don't have to worry about what mode I'm in when I'm editing -- it just fixes it when doing a save-for-web.
    Again, I want to edit in my normal print mode (typically ProPhoto colorspace, and with soft-proofing off or set to the printer/medium combination I expect to use), then do a single operation (might be a multi-step action) to "screw up" my colors so that when I then do a "Save-For-Web", the resulting image, when viewed on the average color-stupid browser, looks like the image I've been seeing in Photoshop.
    Anyone know of such a beast?   I would gladly pay for a plug-in that really works and fixes the problem.
    And if you have other solutions, I'm interested, but the absolute requirement is that it I do one single edit pass for my colors for both print and web use, and I get what I see on the screen in PS on both the prints and on the web display (i.e., working in sRGB/Monitor RGB mode all the time won't cut it). And PREFERABLY, let me do all my editing work in the ProPhoto (or at least AdobeRGB) colorspace so I have a gamut closer to what the printer can do.
    Anyone got a decent solution for this?

    Chris
    I spent all day Googling and doing side by side comparisons of my old and new systems.
    My display is a Dell U2410. It has several presets, including sRGB and Adobe RGB. I've been using sRGB.
    On my OLD system, (Win XP, PsCS2, DwCS4) there seems to be no distinction between color managed and non color managed apps, even on this wide gamut display. I could capture (digital camera) in Adobe RGB, open and edit in PsCS2, save as .psd, convert to CMYK for print, or convert to sRGB for SFW. All images looked identical and they printed and displayed perfectly. I thought this was normal, and seemed logical. This also seems to be the source of my incorrect assumptions. I was trying to get my new machine to behave like my old one.
    So I get this new machine (Windows 7, PsCS5, DwCS5) and now (still in sRGB display mode) all color managed apps appear de-saturated. Non color managed apps are OK. If I switch the display to Adobe RGB, color managed apps are OK, but non color managed apps are way too saturated. From my investigation, I believe this is normal behavior on a wide gamut display. I've tried changing the Control Panel > Display > Screen Resolution > Advanced settings > Color Management options, but to no avail. Either I'm missing something, or Windows 7 is doing color management differently.
    It seems my only option now is to use Adobe RGB display setting for Ps, etc. and switch to sRGB for Dw and non color managed apps. Or, have 2 separate files for print and web. I've Googled 'til my eyes are numb and still not sure I'm getting this. Any enlightenment would be greatly appreciated.
    Finally, I don't see an edit function here, so I can't remove my previous incorrect reply. Moderator, please feel free to do so.
    Thanks

  • Looking for a better solution that tunnel interface

    Hi
    acctualy I have a Vsat connection between my remote site and central office
    on both site we have router and sat modem
    I have now a tunnel interface between my two routers,I am looking for a better idea,,

    hi...
    so you have tunnel interface between your two router so now what are you looking for...?
    secure IPsec connection or what???
    please explaine in details
    regards
    Devang

  • MacBook Air Hard Drive too small - can I run applications from an external drive or is there a better solution?

    I just got a MacBook Air 11" 10.7.2 2GB/64GB.  I love it, but the internal drive is sooo small.  Occasionally I need to take projects home from work or travel with my computer.  Is there any way to run apps (Final Cut Studio, CS5, Office 10, etc) from an external drive?  I am trying to convert over from my Macbook Pro (running Snow Leopard) and I can't seem to find a solution.
    Thanks for your time!
    Samantha

    Samantha,
    It's best to keep your applications on the internal drive and consider external storeage for your data.
    Your choices are direct attached storeage to the USB port (external portable USB drives), storeage on your home or work network, or cloud-based storeage, like DropBox.
    You can also look at slimming down your OSX installation on your MBA by removing unwanted fonts and printer drivers.
    Btw, you will struggle to run CS5 and Final Cut Studio on a MBA with 2GB RAM. Only install the applications you really need on your MBA.
    Can I ask which model MacBook Pro you are migrating from?

  • I have downloaded the converter program and the conversion from PDF to Word is terrible. Is there a better solution or setting?

    I am trying to convert a PDF to Word without re-typing.  I downloaded the converter program onto my MAC but the conversion was terrible.  Unusable.  Is there a better way.  I also have a PC so I could try that as well if would make any difference.

    "Scanned"  Scanned anything starts you with an image / picture of the page content that was on the source paper.
    There is no "renderable" text. OCR can provide an output of text that can be exported. Without that all that is exported is the image.
    As to OCR, Acrobat's ClearScan lends itself to repurpose via the export process.
    Regardless, anything sourced from a scanner output is the "pig's ear" and that'll not yield the "silk purse".
    Export is dictated by the input (GIGO). Export output identifies input quality.
    As a C Student stated a Word file (being well-built helps) that sourced the PDF will yield workable export back to Word.
    PDF's sourced for FrameMaker export rather nicely.
    For optimal export always start with a well-formed Tagged PDF (ISO 14289-1, PDF/UA-1 compliant).
    Two core design considerations of tagged PDF are (1) support Accessible PDF and (2) support export (repurpose) of PDF content. 
    Be well...

Maybe you are looking for