473,397 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,397 software developers and data experts.

Problem with inserting custom types into STL map

Hello, this is my problem:

I have a map:

typedef map<string, bfdb_recordBFDB;

where:

typedef struct
{
size_t seq_no;
StdBloomFilter bf;
} bfdb_record;

where:

class StdBloomFilter : public BloomFilter
{
private:
vector<bool__filter;
size_t __size;
public:
StdBloomFilter():__filter(0),__size(0){};
StdBloomFilter(size_t _size): __filter(_size), __size(_size) {};
StdBloomFilter(const StdBloomFilter& _source);

virtual ~StdBloomFilter(){};

operator CountingBloomFilter();
StdBloomFilter& operator=(const StdBloomFilter&);

void set(size_t _pos);
bool test(size_t _pos) const;

void clear();
size_t size() const;
void merge(const StdBloomFilter& _source);

string to_string();
};

now I want to insert structure into my map:

__db.insert(make_pair(_id,_info));
or
__db[_id] = _info;
or
__db.insert(BFDB::value_type(_id, _info));

I get a runtime error:

8 [main] LE 2560 _cygtls::handle_exceptions: Exception:
STATUS_ACCESS_VIOLATION
985 [main] LE 2560 open_stackdumpfile: Dumping stack trace to
LE.exe.stackdump

Is something in StdBloomFilter missing. If I change bf to int type in
the bfdb_record struct then everything works, but that is not what I
need!!!

Please help

Apr 2 '07 #1
10 2600
ua****@gmail.com wrote:
Hello, this is my problem:

I have a map:

typedef map<string, bfdb_recordBFDB;

where:

typedef struct
{
size_t seq_no;
StdBloomFilter bf;
} bfdb_record;
That's C. You want

struct bfdb_record
{
size_t seq_no;
StdBloomFilter bf;
};

Are you sure you want to copy the entire StdBloomFilter object each time
you do an insert?
where:

class StdBloomFilter : public BloomFilter
{
private:
vector<bool__filter;
size_t __size;
Those are illegal names, anything starting with double underscore is
reserved.
>
now I want to insert structure into my map:

__db.insert(make_pair(_id,_info));
or
__db[_id] = _info;
or
__db.insert(BFDB::value_type(_id, _info));

I get a runtime error:
What does your StdBloomFilter copy constructor do?

--
Ian Collins.
Apr 2 '07 #2
StdBloomFilter& StdBloomFilter::operator=(const StdBloomFilter&
_source)
{
this->__size=_source.__size;
this->__filter =_source.__filter;
}

And what should it do? These are no pointers. These should be copies
by value, right? It was not working, so I added this dummy copy
constructor, but it still does not work.

Apr 2 '07 #3
ua****@gmail.com wrote:

Please quote the appropriate context, this post makes no sense on its own.
StdBloomFilter& StdBloomFilter::operator=(const StdBloomFilter&
_source)
{
this->__size=_source.__size;
this->__filter =_source.__filter;
You realy should get rid of these illegal names.
}

And what should it do? These are no pointers. These should be copies
by value, right? It was not working, so I added this dummy copy
constructor, but it still does not work.
Run you code under a debugger and see what it is doing. You don't show
the base class, so the problem may well be in there.

--
Ian Collins.
Apr 2 '07 #4
On Apr 2, 4:29 pm, Ian Collins <ian-n...@hotmail.comwrote:
uar...@gmail.com wrote:

Please quote the appropriate context, this post makes no sense on its own.
StdBloomFilter& StdBloomFilter::operator=(const StdBloomFilter&
_source)
{
this->__size=_source.__size;
this->__filter =_source.__filter;

You realy should get rid of these illegal names.
}
And what should it do? These are no pointers. These should be copies
by value, right? It was not working, so I added this dummy copy
constructor, but it still does not work.

Run you code under a debugger and see what it is doing. You don't show
the base class, so the problem may well be in there.

--
Ian Collins.
I can put StdBloomFilter object into a vector<StdBloomFilterand I
tried to get rid of any base class - does not help. Base class is an
abstract interface.

Apr 2 '07 #5
ua****@gmail.com wrote:
On Apr 2, 4:29 pm, Ian Collins <ian-n...@hotmail.comwrote:
>>uar...@gmail.com wrote:

Please quote the appropriate context, this post makes no sense on its own.
>>>StdBloomFilter& StdBloomFilter::operator=(const StdBloomFilter&
_source)
{
this->__size=_source.__size;
this->__filter =_source.__filter;

You realy should get rid of these illegal names.
>>>}
>>>And what should it do? These are no pointers. These should be copies
by value, right? It was not working, so I added this dummy copy
constructor, but it still does not work.

Run you code under a debugger and see what it is doing. You don't show
the base class, so the problem may well be in there.
*Please* don't quote signatures - the bit after the "-- ".
>
I can put StdBloomFilter object into a vector<StdBloomFilterand I
tried to get rid of any base class - does not help. Base class is an
abstract interface.
What did your debugger show?

--
Ian Collins.
Apr 2 '07 #6
On Apr 2, 4:40 pm, Ian Collins <ian-n...@hotmail.comwrote:
uar...@gmail.com wrote:
On Apr 2, 4:29 pm, Ian Collins <ian-n...@hotmail.comwrote:
>uar...@gmail.com wrote:
>Please quote the appropriate context, this post makes no sense on its own.
>>StdBloomFilter& StdBloomFilter::operator=(const StdBloomFilter&
_source)
{
this->__size=_source.__size;
this->__filter =_source.__filter;
>You realy should get rid of these illegal names.
>>}
>>And what should it do? These are no pointers. These should be copies
by value, right? It was not working, so I added this dummy copy
constructor, but it still does not work.
>Run you code under a debugger and see what it is doing. You don't show
the base class, so the problem may well be in there.

*Please* don't quote signatures - the bit after the "-- ".
I can put StdBloomFilter object into a vector<StdBloomFilterand I
tried to get rid of any base class - does not help. Base class is an
abstract interface.

What did your debugger show?

--
Ian Collins.
This is what I can catch:

mi_cmd_var_create: unable to create variable object
Single stepping until exit from function ntdll!
LdrDisableThreadCalloutsForDll,
which has no line number information.
Single stepping until exit from function ntdll!
LdrFindCreateProcessManifest,
which has no line number information.
Single stepping until exit from function ntdll!RtlCheckRegistryKey,
which has no line number information.

I compile it in gcc. I installed cygwin on a Windows system and I
debug it in Eclipse. So, this is all I managed to get out of it.

Apr 2 '07 #7
ua****@gmail.com wrote:
On Apr 2, 4:40 pm, Ian Collins <ian-n...@hotmail.comwrote:
>>uar...@gmail.com wrote:
>>>On Apr 2, 4:29 pm, Ian Collins <ian-n...@hotmail.comwrote:
>>>>uar...@gmail.com wrote:
>>>>Please quote the appropriate context, this post makes no sense on its own.
>>>>>StdBloomFilter& StdBloomFilter::operator=(const StdBloomFilter&
>_source)
>{
this->__size=_source.__size;
this->__filter =_source.__filter;
>>>>You realy should get rid of these illegal names.
>>>>>}
>>>>>And what should it do? These are no pointers. These should be copies
>by value, right? It was not working, so I added this dummy copy
>constructor, but it still does not work.
>>>>Run you code under a debugger and see what it is doing. You don't show
the base class, so the problem may well be in there.

*Please* don't quote signatures - the bit after the "-- ".

>>>I can put StdBloomFilter object into a vector<StdBloomFilterand I
tried to get rid of any base class - does not help. Base class is an
abstract interface.

What did your debugger show?
*Please* *Please* don't quote signatures - the bit after the "-- ".
>
This is what I can catch:

I compile it in gcc. I installed cygwin on a Windows system and I
debug it in Eclipse. So, this is all I managed to get out of it.
You should be able to see the last line in your code.

I assume you have implemented the assignment operator as well?

--
Ian Collins.
Apr 2 '07 #8
On Apr 2, 4:52 pm, Ian Collins <ian-n...@hotmail.comwrote:
uar...@gmail.com wrote:
On Apr 2, 4:40 pm, Ian Collins <ian-n...@hotmail.comwrote:
>uar...@gmail.com wrote:
>>On Apr 2, 4:29 pm, Ian Collins <ian-n...@hotmail.comwrote:
>>>uar...@gmail.com wrote:
>>>Please quote the appropriate context, this post makes no sense on its own.
>>>>StdBloomFilter& StdBloomFilter::operator=(const StdBloomFilter&
_source)
{
this->__size=_source.__size;
this->__filter =_source.__filter;
>>>You realy should get rid of these illegal names.
>>>>}
>>>>And what should it do? These are no pointers. These should be copies
by value, right? It was not working, so I added this dummy copy
constructor, but it still does not work.
>>>Run you code under a debugger and see what it is doing. You don't show
the base class, so the problem may well be in there.
>*Please* don't quote signatures - the bit after the "-- ".
>>I can put StdBloomFilter object into a vector<StdBloomFilterand I
tried to get rid of any base class - does not help. Base class is an
abstract interface.
>What did your debugger show?

*Please* *Please* don't quote signatures - the bit after the "-- ".
This is what I can catch:
I compile it in gcc. I installed cygwin on a Windows system and I
debug it in Eclipse. So, this is all I managed to get out of it.

You should be able to see the last line in your code.

I assume you have implemented the assignment operator as well?
--
Ian Collins.

Well the assignment is smth like:
bool BFDatabase::update(const string& _id, const bfdb_record& _info)
{
BFDB::iterator iter = __db.find(_id);

if (iter==__db.end())
{
//__db.insert(make_pair(_id,_info));
__db[_id] = _info;
//__db.insert(BFDB::value_type(_id, _info));
return true;
}
return false;
}

But the problem is the following:

This works:
StdBloomFilter bf(100);
vector<StdBloomFiltervec;
vec.push_back(bf);

And this does not:
map<int,StdBloomFilterm;
m.insert(make_pair(5,bf));
Apr 3 '07 #9
ua****@gmail.com wrote:
StdBloomFilter& StdBloomFilter::operator=(const StdBloomFilter&
_source)
[...]
It was not working, so I added this dummy copy
constructor,
This is not the copy ctor. Show us your

StdBloomFilter::StdBloomFilter( const StdBloomFilter& );
Apr 3 '07 #10
ua****@gmail.com wrote:
Hello, this is my problem:

I have a map:

typedef map<string, bfdb_recordBFDB;

where:

typedef struct
{
size_t seq_no;
StdBloomFilter bf;
} bfdb_record;

where:

class StdBloomFilter : public BloomFilter
{
private:
vector<bool__filter;
Stop right there. You have just created an ill-formed program. Any
identifier with two consecutive underscores is reserved to the
implementation; you may not use it for your own purposes.
>[remainder redacted]
Apr 3 '07 #11

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

Similar topics

0
by: Nick Caldwell | last post by:
Y'all, Problem: Reading complex data types returned from WSDL I'll present this in 3 sections. 1. Output of WSDL parser on Google API 2. Output of WSDL parser on Custom API 3. WSDL parser...
3
by: Omer van Kloeten | last post by:
The Top Level Design: The class Base is a factory class with a twist. It uses the Assembly/Type classes to extract all types that inherit from it and add them to the list of types that inherit...
6
by: trexim | last post by:
Hi, I am trying to create a Web Reference for CSTA using the URL http://www.ecma-international.org/standards/ecma-348/csta-wsdl/csta-wsdl-all-operations.wsdl Visual .Net complains that: "...
3
by: Mahesh Devjibhai Dhola | last post by:
Hi All, I want to make a custom class in c#, which extends System.Xml.XmlNode class of BCL. Now in custom class, I have implement abstract methods of XmlNode class also. Now when I am trying to...
2
by: Edward Diener | last post by:
In C++ an overridden virtual function in a derived class must have the exact same signature of the function which is overridden in the base class, except for the return type which may return a...
2
by: pmcguire | last post by:
I am reposting in this group after getting no response for a week in the deployment group. I have a setup project that uses custom actions. The project installs and runs fine on machines that...
0
by: rokuingh | last post by:
ok, so i've been working on this one for quite a while, and the code is very big so i'm just going to give the relevant parts. this is a program that builds polymers (chemical structures of repeated...
12
by: Ron M. Newman | last post by:
Hi, I can load an assembly using the Assembly.Load(....) However, I'd like dynamic loading of assemblies to be identical to putting an assembly reference in your VS2005 project. and yes, I...
2
by: AlexanderDeLarge | last post by:
Hi! I got a problem that's driving me crazy and I'm desperately in need of help. I'll explain my scenario: I'm doing a database driven site for a band, I got these tables for their discography...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.