473,467 Members | 1,547 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Data structure for Counter frequence of Pairs

to count the frequence of each pair like <A,B> <A2,C2> in the following.
eg. <<A, B>, 6>
<<A, B1>, 8>
<<A, B2>, 4>
<<A2, C2>, 10>
<<A3, D2>, 16>
I try to use
typedef std::pair<long, long> AddrPair;
typedef HASH_MAP<AddrPair,int> PairCount;
AddrPair addrPair;
PariCount pairCount;

then use it like:
addrPair.first = 100;
addrPair.sencond = 200; //upto here it compiles ok.

PairCount::iterator pit=pairCount.find(addrPair);
it complains like:

no match for call to '(const __gnu_cxx::hash<std::pair<PAddr, PAddr> >)
(const std::pair<PAddr, PAddr>&)'

Does anybody know what's wrong here, or any suggestion to build a data
structure to solve the problem?

Thanks.

Jul 23 '05 #1
1 1476
Solved!
need to define a hashfunction for the hash map.
class hashfunction {
public:
size_t operator()(const AddrPair *v) const {
size_t val = (size_t)v;
return val>>2;
}
};
typedef HASH_MAP<AddrPair*,int, hashfunction> PairCount;

"Jianli Shen" <ji****@cc.gatech.edu> wrote in message
news:d7**********@news-int.gatech.edu...
to count the frequence of each pair like <A,B> <A2,C2> in the following.
eg. <<A, B>, 6>
<<A, B1>, 8>
<<A, B2>, 4>
<<A2, C2>, 10>
<<A3, D2>, 16>
I try to use
typedef std::pair<long, long> AddrPair;
typedef HASH_MAP<AddrPair,int> PairCount;
AddrPair addrPair;
PariCount pairCount;

then use it like:
addrPair.first = 100;
addrPair.sencond = 200; //upto here it compiles ok.

PairCount::iterator pit=pairCount.find(addrPair);
it complains like:

no match for call to '(const __gnu_cxx::hash<std::pair<PAddr, PAddr> >)
(const std::pair<PAddr, PAddr>&)'

Does anybody know what's wrong here, or any suggestion to build a data
structure to solve the problem?

Thanks.

Jul 23 '05 #2

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

Similar topics

7
by: Steve D. Perkins | last post by:
Hello all - I'm a Java and C++ developer, looking to pick up some Python and wxPython skills for prototyping and quick projects. I've been developing for about 15 years, and am very familiar...
5
by: Carlos Ribeiro | last post by:
Hello all, I'm posting this to the list with the intention to form a group of people interested in this type of solution. I'm not going to spam the list with it, unless for occasional and...
5
by: Jeff | last post by:
I've created a beast! Here is my data structure: $VAR1 = 'bunkers'; $VAR2 = { 'items' => , \ ] }; $VAR3 = 'simpsons'; $VAR4 = {
0
by: Fabian Kr?ger | last post by:
Hello, I got a weird problem and need your help and ideas... I´ve written an php application which imports data in XML format and writes this data to a MySQL database to have a faster access....
7
by: Excluded_Middle | last post by:
Suppose I have a struct typdef struct foo { int age; char *name; }foo; now I made a list of foo using
22
by: Curious | last post by:
Hi, I am searching for a data structure that stores key-value pairs in it. This data structure is to hold large amounts of key-value pairs, and so needs to be efficient both in insertion and...
1
by: Alan T | last post by:
I have pairs of data: peter - manager mary - secretary john - accountant alan - security What data structure is suitable for storing these data pairs so that I can get the counterpart ? If I...
1
by: yucefrizk | last post by:
hello all, I'm trying to write a code to retreive data from a database to an excel file, I achieved my code and everything is going good by running it through unix, but when I create a webpage to...
13
by: umpsumps | last post by:
Hello, Here is my code for a letter frequency counter. It seems bloated to me and any suggestions of what would be a better way (keep in my mind I'm a beginner) would be greatly appreciated.. ...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.