hash_set
is an extension that is not part of the C++ standard. Lookups should be O(1) rather than O(log n) for set
, so it will be faster in most circumstances.
Another difference will be seen when you iterate through the containers. set
will deliver the contents in sorted order, while hash_set
will be essentially random (Thanks Lou Franco).
Edit: The C++11 update to the C++ standard introduced unordered_set
which should be preferred instead of hash_set
. The performance will be similar and is guaranteed by the standard. The “unordered” in the name stresses that iterating it will produce results in no particular order.
Related Posts:
- what does O(N) mean [duplicate]
- How to check that an element is in a std::set?
- How to get current time in milliseconds?
- What is the easiest way to initialize a std::vector with hardcoded elements?
- C++ Double Address Operator? (&&)
- How do I erase an element from std::vector<> by index?
- Is it more efficient to copy a vector by reserving and copying, or by creating and swapping? [duplicate]
- How do I reverse a C++ vector?
- Convert Set to List without creating new List
- Returning an empty string : efficient way in c++
- A proper way to create a matrix in c++
- Measure the time it takes to execute a t-sql query
- A proper way to create a matrix in c++
- Why does the C++ STL not provide any “tree” containers?
- How to iterate through a list of objects in C++?
- How to remove all the occurrences of a char in c++ string
- push_back vs emplace_back
- Which Python memory profiler is recommended? [closed]
- How to find if a given key exists in a C++ std::map
- Parsing a comma-delimited std::string
- What is the difference between spark.sql.shuffle.partitions and spark.default.parallelism?
- Python Sets vs Lists
- How to ensure that a std::map is ordered?
- HashSet vs. ArrayList
- push_back vs emplace_back
- Returning an empty string : efficient way in c++
- Remove spaces from std::string in C++
- What is the difference between const_iterator and non-const iterator in the C++ STL?
- Remove spaces from std::string in C++
- What’s the most efficient way to erase duplicates and sort a vector?
- Best way to extract a subvector from a vector?
- How to sum up elements of a C++ vector?
- Implementation of Vector in C++
- Appending a vector to a vector
- Determine if map contains a value for a key?
- Initializing a static std::map
in C++ - C++ Erase vector element by value rather than by position?
- Static linking vs dynamic linking
- Use the auto keyword in C++ STL
- How to calculate the intersection of two sets?
- Is Python faster and lighter than C++?
- std::string length() and size() member functions
- When should we use Radix sort?
- OpenMP set_num_threads() is not working
- Java check if boolean is null
- How to sort a HashSet?
- What is the best way to profile javascript execution?
- sorting in std::map where key is a std::string
- How to do std::string indexof in C++ that returns index of matching string?
- the asymptotic growth of n choose floor(n/2)
- How to parallelize downloads across hostnames on WordPress?
- How to parallelize downloads across hostnames on WordPress?
- Get difference between two lists
- Why can’t I make a vector of references?
- C++ equivalent of StringBuffer/StringBuilder?
- Displaying contents of a vector container in C++
- List iterator not dereferencable?
- C++ performance vs. Java/C#
- Steps to optimize WordPress in regard to server load and website speed?
- How well does WordPress scale?
- What are the best practices for using a caching plugin on a shared host?
- Slow Query for the wp_options table
- What is the best caching option for WordPress multi-site on non-shared hosting?
- How can I debug the TTFB in WP?
- What’s the difference between wp_insert_user() and wp_create_user()
- How to fix wordpress slow first time load (Local Server)?
- What’s the ideal way to profile WordPress memory usage?
- WordPress SLOW, tried everything!
- Localized WordPress is much slower?
- W3 Leverage browser caching not working for google pagespeed [closed]
- How many posts can I have in a WordPress website?
- WordPress so slow to load on MAMP
- Do multiple revisions really slow down WordPress?
- get_adjacent_post alternative on a very large db
- Fastest server stack configuration for WordPress?
- Cache WordPress translations
- Website is slow: advice on optimization
- Can we have a post without a slug?
- Refresh external feeds only in cron?
- Use override_load_textdomain for cache translation and improve performance
- What is the proper use of https in a modern E-Commerce environment?
- Combine JS and CSS for WordPress admin
- Any reason why wp_cache_set not to work?
- Will removing revisions positively impact database performance?
- Is WordPress fast enough for a heavy traffic project?
- What are best practices for configuring a server for WordPress sites?
- Does a WP site consumes memory resources when there are NO visitors?
- Extremely slow WordPress website with 6000 posts
- In terms of performance – Is unmanaged VPS better than a managed one – for WP sites?
- Utilize WordPress Authentication Only
- How can WordPress be made more memory efficient?
- WordPress tries to load “next page” after done loading current page
- Get Y random authors’ ID/Object with more than X number of posts
- What is a reasonable get_num_queries() result?
- Speeding Up Bulk Post Creation – wp_insert_post & update_post_meta
- How to properly insert a stylesheet in wp_head
- Performance impact of using functions in WordPress?
- Localization / textdomain is slow and chaotic
- Disable Outbound Web Requests
- WordPress performance issue. Can I debug it?