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 9113745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:02:08+00:00 2026-06-17T04:02:08+00:00

I have a vector of min priority queues, each one created with different instance

  • 0

I have a vector of min priority queues, each one created with different instance of custom comparator class. Queues are supposed to be limited in size, and in case the queue is full, only element with higher priority than top of the queue can be inserted and kick out the element on top. So before inserting into full queue I want to compare new element against the top of the queue using the queues’ own comparator to avoid the insertion/deletion cost. Is that possible to do without recreating the comparator?

Edit:
@Kerrek’s hack is really cool but the comparators do have to be created by constructor with parameter, I should’ve mentioned that. So I went with @Spundun answer, also I used access to underlying container for faster printing.

  • 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-06-17T04:02:09+00:00Added an answer on June 17, 2026 at 4:02 am

    the comparator is a protected member(named comp, +1 Nate). So if you derive your own priority queue class from the stl class, and implement the functionality you described as a function (say insert_only_if_important() ) then you can access the comparator from within that function.

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

Sidebar

Related Questions

I have created the code to perform a mapping of points from one vector
I have a vector class and I defined the __mul__ method to multiply a
I have a vector where I keep an incrementing data. Normally each element of
I have a vector with a min of two points in space, e.g: A
I have two vectors of integers, and for each element of the second vector
I have a Max Angle and a Min Angle, and also a unit vector
I have a vector of points stored in a std::vector instance. I want to
Hi every one I have the following problem I need to build a vector
I have vector< pair<int, int>> myVec (N); I want to have all pairs initialized
in clojure i have vector [myfn1 myfn2 myfn3] how can i call functions named

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.