473,320 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

hash_set help

I'm having trouble with hash_set's insert. It's not supposed to allow
the same element to be insert more than once, but this is what is
happening for me. My question is, what function does it use to compare
elements to see if it's already in set? Is it the EqualKey struct? The
== operator for the element it contains?

Thanks in advance,
-- Breck Fresen

May 15 '06 #1
2 1823
breck <br******@comcast.net> wrote:
I'm having trouble with hash_set's insert. It's not supposed to allow
the same element to be insert more than once, but this is what is
happening for me. My question is, what function does it use to compare
elements to see if it's already in set? Is it the EqualKey struct? The
== operator for the element it contains?


I don't know about hash_set, but if it's anything like std::set or
std::map then by default is uses operator< for the comparison, unless
you specify otherwise.

--
Marcus Kwok
Replace 'invalid' with 'net' to reply
May 15 '06 #2
Marcus Kwok wrote:
breck <br******@comcast.net> wrote:
I'm having trouble with hash_set's insert. It's not supposed to allow
the same element to be insert more than once, but this is what is
happening for me. My question is, what function does it use to compare
elements to see if it's already in set? Is it the EqualKey struct? The
== operator for the element it contains?


I don't know about hash_set, but if it's anything like std::set or
std::map then by default is uses operator< for the comparison, unless
you specify otherwise.


Probably it doesn't use operator< since a hash_set has no notion of
sorted keys in the way that std::set and its cousins do.

Since hash_set is not standard C++ this is implementation dependent. If
you use the SGI implementation, and your question suggests that you do,
then yes the EqualKey function object determines whether the keys are
equal. By default this is std::equal_to<Key> which in turn uses
operator== to test for equality.
May 15 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Vasileios | last post by:
Hello could someone help me please. I have the following class definition #include <ext/hash_set> #include "tool.h" class ToolContainer : public QObject {
1
by: Abhijit Ray | last post by:
I am using hash_set which is available from gcc ( and which i presume is not part of the C++ standard yet ) okay , In hash tables the key is used by a hash function to calculate a index and the...
10
by: Alex Gerdemann | last post by:
Hello, I have spent a bunch of time converting a Java program I wrote to C++ in order to improve performance, and have found that it is not necessarily faster. Specifically, I'm writing a...
5
by: Bart Blommerde | last post by:
Hi, My question is about the STL extensions hash_set and hash_map, especially the SGI versions of these templates. When defining a class like this : #include <hash_set> class MyClass : public...
1
by: Timo Qvist | last post by:
Hi, I'm a bit new to STL and really new to SGI's hash_set implementation and I've having problem instantiating a hash_set with a custom hash function, I could really use some help sifting through...
3
by: Markus Dehmann | last post by:
I have a class "Data" and I store Data pointers in an STL set. But I have millions of inserts and many more lookups, and my profiler found that they cost a lot of runtime. Therefore, I want to...
8
by: Rakesh | last post by:
Hi - What is wrong this implementation? I get a core dump at the free() statement? Thanks Rakesh #include <ext/hash_map> #include <iostream.h> #include <ext/hash_set>
2
by: Paulo da Silva | last post by:
Hi. I have a class Foo with a string. I want to store its elements in a hash_set beeing the hash executed over the string. How do I do that? class Foo { ... string s; ...
5
by: Markus Dehmann | last post by:
Do I have to handle hash collisions in a hash_set myself? I did a test in which I use find() to look for objects in a hash_set. These objects are definitely not contained, but find() sometimes...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.