counting paired elements in a Vector

I have the following functions that pairup different elements in the container, I want to cont the pairs by using the function that sorted them in the first place.
Help me identify the right parameters to set for the count.

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
bool compareBidList(Bid one, Bid two) { 
 
        if (one.type == 'A' && two.type == 'B') 
                return (one.price < two.price); 
 
        return false; 
} 
 
// comparator function for type: returns true when x belongs before y 
bool compare_bid_type( const Bid& x, const Bid& y ) 
{ 
        return x.type <= y.type; 
} 
 
// comparator function for price: returns true when x belongs before y 
bool compare_bid_price( const Bid& x, const Bid& y ) 
{ 
        return x.price <= y.price; 
} 
 
void sort( BidList &bidlist ) 
{ 
    stable_sort( bidlist.begin(), bidlist.end(), compare_bid_type ); 
    stable_sort( bidlist.begin(), bidlist.end(), compare_bid_price ); 
}

//int countPairs( BidList &(sort( BidList &bidlist)// count the paired bids
//{
//    BidList::const_iterator itr = sort( BidList &bidlist).begin();
//    while (itr != sort( BidList &bidlist ).end())
//          { 
//            count (sort(bidlist));                                            
//            //count(sort(bidlist));
//            show(*itr++);  
//    }
//    }

//Should count all the paired bids and the unpaired bids
int count( BidList &bidlist )
{
 BidList::const_iterator itr = (sort(bidlist)).begin();
 while (itr != (sort(bidlist)).end())                                             
 count(bidlist);
 show(*itr++);  
} 

What exactly is a "paired bid"?

I don't think that compareBidList will work as a functor for the sort.
http://en.wikipedia.org/wiki/Strict_weak_ordering
What do you think that this function does?

1
2
3
4
5
void sort( BidList &bidlist ) 
{ 
    stable_sort( bidlist.begin(), bidlist.end(), compare_bid_type ); 
    stable_sort( bidlist.begin(), bidlist.end(), compare_bid_price ); 
}

Well
void sort( BidList &bidlist )
{
stable_sort( bidlist.begin(), bidlist.end(), compare_bid_type );
stable_sort( bidlist.begin(), bidlist.end(), compare_bid_price );
}

does the matching of bids as instructed in the funnctions above it, it really has no problem.just want to know how I can count the elements in a container which have been compaired and matched up.
Topic archived. No new replies allowed.