How to match values in a Map container.

Discussion in 'General Computer Support' started by gnwillix88, May 17, 2010.

  1. gnwillix88

    gnwillix88

    Joined:
    May 17, 2010
    Messages:
    1
    I am trying to match values in map container.Can anyone guide me on this.

    This is the function I use for the matching!
    values in the map:
    Key | trdId | qty | type | price

    1 2 10 A 100
    2 1 10 B 120
    3 2 10 A 100
    4 1 12 B 115

    Conditions for the matching: price of B > price of A
    one type == 'A' while the other is type=='B'

    I move the matched bids to another container called Sorted.

    I tried as below, but there were no results shown.when I check the Sorted contain for size, it shows its empty.
    Code:
    map<int, Bid*>bidtable
    map<int, Bid*>::const_iterator iter;
    
    map<int, Bid*> Auctioneer::compareBidList(map<int, Bid*>& one, map<int, Bid*>& two) // pass references &
    {
        map<int, Bid*> Sorted;
        map<int, Bid*>::iterator iterOne;
        map<int, Bid*>::iterator iterTwo;
    	for(iterOne = one.begin(); iterOne != one.end(); ++iterOne)
    	{
    		if(iterOne->second->bidType == 'A') // select all type A from one
    		{
    			map<int, Bid*>::iterator iterTwo;
    			for(iterTwo = two.begin(); iterTwo != two.end(); ++iterTwo)
    			{
    				if(iterTwo->second->bidType == 'B') // select all type B from two
    				{
    					if(iterOne->second->price < iterTwo->second->price) // select on price between type A and type B
    					{
                            Sorted.insert(*iterOne);
    						Sorted.insert(*iterTwo);
    					}
    				}
    			}
    		}
    	}
     return Sorted;
    }
    
    
    
    
    
    
    
    
    
     
    Last edited: May 17, 2010
    gnwillix88, May 17, 2010
    #1
    1. Advertising

  2. gnwillix88

    jettlee1

    Joined:
    Apr 22, 2010
    Messages:
    13
    you have error in this message.
     
    jettlee1, May 20, 2010
    #2
    1. Advertising

  3. gnwillix88

    honeydanny84

    Joined:
    Jan 11, 2010
    Messages:
    5
    yeah~~~~ i think
     
    honeydanny84, May 21, 2010
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tree Feller

    Encrypted container on DVDRW - best method?

    Tree Feller, Dec 22, 2004, in forum: Computer Security
    Replies:
    0
    Views:
    530
    Tree Feller
    Dec 22, 2004
  2. goneill

    OT: Container space leaving UK feb/march

    goneill, Jan 23, 2004, in forum: NZ Computing
    Replies:
    0
    Views:
    353
    goneill
    Jan 23, 2004
  3. Marc Wossner

    Raw values and exposure values

    Marc Wossner, Jun 19, 2008, in forum: Digital Photography
    Replies:
    0
    Views:
    375
    Marc Wossner
    Jun 19, 2008
  4. chris
    Replies:
    1
    Views:
    462
    alexd
    Jun 19, 2008
  5. M D
    Replies:
    2
    Views:
    1,283
Loading...

Share This Page