Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > General Computer Discussion > General Computer Support > How to match values in a Map container.

Reply
Thread Tools

How to match values in a Map container.

 
 
gnwillix88 gnwillix88 is offline
Junior Member
Join Date: May 2010
Posts: 1
 
      05-17-2010
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 by gnwillix88; 05-17-2010 at 07:48 AM..
Reply With Quote
 
 
 
 
jettlee1 jettlee1 is offline
Junior Member
Join Date: Apr 2010
Posts: 13
 
      05-20-2010
you have error in this message.
 
Reply With Quote
 
 
 
 
honeydanny84 honeydanny84 is offline
Junior Member
Join Date: Jan 2010
Posts: 5
 
      05-21-2010
yeah~~~~ i think
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
getting values in a map - map wrapper class Angus C++ 12 10-02-2007 08:25 AM
pat-match.lisp or extend-match.lisp in Python? ekzept Python 0 08-10-2007 06:08 PM
$match = true() for empty $match?? Victor XML 2 05-17-2004 10:43 AM
Java regex can't match lengthy match? hiwa Java 0 01-29-2004 10:09 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57