Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7061905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:31:49+00:00 2026-05-28T04:31:49+00:00

I am making a poker evaluator, and for the histogram I am using vector<

  • 0

I am making a poker evaluator, and for the histogram I am using vector< pair > to hold data. Now I am stuck on sorting them, whatever I try I get compiler error.

Any help is appreciated, thanks.

class Histogram {
private:
    vector< pair<int,int> > _rankHistogram;
    vector< pair<int,int> > _suitHistogram;

    void add(int rank, int suit) {
        for (int i=0; i < _rankHistogram.size(); i++)
            if (_rankHistogram[i].first == rank) { _rankHistogram[i].second++; break; }

        for (int i=0; i < _suitHistogram.size(); i++)
            if (_suitHistogram[i].first == suit) { _suitHistogram[i].second++; break; }
    }
    bool cmp_big_first (pair<int,int> i, pair<int,int> j) { return i.second < j.second; }

public:
    Histogram() {
        _rankHistogram.push_back( make_pair(TWO, 0) );
        _rankHistogram.push_back( make_pair(THREE, 0) );
        _rankHistogram.push_back( make_pair(FOUR, 0) );
        _rankHistogram.push_back( make_pair(FIVE, 0) );
        _rankHistogram.push_back( make_pair(SIX, 0) );
        _rankHistogram.push_back( make_pair(SEVEN, 0) );
        _rankHistogram.push_back( make_pair(EIGHT, 0) );
        _rankHistogram.push_back( make_pair(NINE, 0) );
        _rankHistogram.push_back( make_pair(TEN, 0) );
        _rankHistogram.push_back( make_pair(JACK, 0) );
        _rankHistogram.push_back( make_pair(QUEEN, 0) );
        _rankHistogram.push_back( make_pair(KING, 0) );
        _rankHistogram.push_back( make_pair(ACE, 0) );

        _suitHistogram.push_back( make_pair(SPADES, 0) );
        _suitHistogram.push_back( make_pair(HEARTS, 0) );
        _suitHistogram.push_back( make_pair(DIAMONDS, 0) );
        _suitHistogram.push_back( make_pair(CLUBS, 0) );
    }

    void operator() (Card &c) { add(c.getRank(), c.getSuit()); }

    void h_sort() {
        sort(_rankHistogram.begin(), _rankHistogram.end(), cmp_big_first);
    }

    void h_print() {
        for (int i=0; i<_rankHistogram.size(); i++) {
            cout << Card::rankToString(_rankHistogram[i].first) << "\t\t" << _rankHistogram[i].second << endl;
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:31:50+00:00Added an answer on May 28, 2026 at 4:31 am

    You need to make it static cmp_big_first. Without being static, the method takes an implicit this parameter (of the class type), which does not make sense for your usage.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am making a GUI (using swing) for a poker framework and need some
Making an adobe flex ui in which data that is calculated must use proprietary
When making changes using SubmitChanges() , LINQ sometimes dies with a ChangeConflictException exception with
I've been making some progress with audio programming for iPhone. Now I'm doing some
I'm making a turned based poker game and trying to figure out the best
I am making game for android using libgdx my requirement is that when character
I'm making a game with my friend. Now there is a question about levels.
Let me first try to explain what I'm trying to achieve. I'm making a
Im making a simple poker script in PHP and up to the point where
Making echo of a question around the web: Is the syntax for svn:ignore patterns

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.