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

  • Home
  • SEARCH
  • 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 9273903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:13:26+00:00 2026-06-18T16:13:26+00:00

Is there a unique container such like std::list with simple functionality ( push ,

  • 0

Is there a unique container such like std::list with simple functionality (push,pop,clear, etc.) and not sorted order unlike std::set, or maybe I need to extend std::list and add my own push_unique method )) ?

  • 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-18T16:13:27+00:00Added an answer on June 18, 2026 at 4:13 pm

    The STL is supposed to provide efficient containers.

    A container which does not allow duplicates needs to support fast lookup to determine whether the value you want to is already present in the collection or not.

    std::set keeps the item sorted in a red-black tree, which is what allows an O(log(n)) lookup, insertion, and removal.

    std::unsorted_set allows constant-time lookup, insertion, and removal, but you need to provide a hash function for most UDT types, you need to take care of issues such as rehashing, which cause iterator invalidation, and you do not have any defined order for your items (not even the insertion order).

    If you want to use a simple collection such as std::vector without allowing duplicates, you need to provide your own adapter.

    However, I still can’t figure out why you have problems with a sorted container such as std::set if, as you say, the order doesn’t matter for you.

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

Sidebar

Related Questions

std::auto_ptr is not allowed to be stored in an STL container, such as std::vector
I have a set of unique elements (there are not two identical elements). And
I'd like to know if there's some faster way to sort such array than
I have a variable name subject. For each unique subject there are 240 response
Is there a way to get a unique machine-specific system ID in a Flex
Is there any method like the array_unique for objects? I have a bunch of
Is there a JavaScript way to store data that is unique to a browser
Scenario: There is a website with 700-900 concurrent unique visitors at any given time.
Summary : is there a way to get the unique lines from a file
Is there a way to set the NULL_DISTINCT_FOR_UNIQUE to 1 for UNIQUE constraints to

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.