473,408 Members | 1,840 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,408 software developers and data experts.

set of structs (intersection)

Hi,

Let us consider the following code fragment:

struct TAnnotation {
int x, y;

};

struct TAnnotationLT
{
bool operator()(const TAnnotation& a1, const TAnnotation& a2) const {
return ( (a1.x < a2.x) ||
( (a1.x == a2.x) && (a2.y < a2.y) ) );
}

};

typedef set<TAnnotation, TAnnotationLT> TAnnotationsSet;

TAnnotationsSet s1, s2, s3;

I would like to put in s3 the intersection between the sets s1 and s3.
If I do:

set_intersection(as1.begin(), as1.end(), as2.begin(), as2.end(),
std::inserter(as3, as3.begin()));

I get the following compilation error:
/usr/include/c++/3.4.3/bits/stl_algo.h: In function `_OutputIterator
std::set_intersection(_InputIterator1, _InputIterator1,
_InputIterator2, _InputIterator2, _OutputIterator) [with
_InputIterator1 = std::_Rb_tree_const_iterator<TAnnotation>,
_InputIterator2 = std::_Rb_tree_const_iterator<TAnnotation>,
_OutputIterator = std::insert_iterator<TAnnotationsSet>]':
prova2.cpp:63: instantiated from here
/usr/include/c++/3.4.3/bits/stl_algo.h:4210: error: no match for
'operator<' in
'(&__first1)->std::_Rb_tree_const_iterator<_Tp>::operator* [with _Tp =
TAnnotation]() <
(&__first2)->std::_Rb_tree_const_iterator<_Tp>::operator* [with _Tp =
TAnnotation]()'
prova2.cpp:63: instantiated from here
/usr/include/c++/3.4.3/bits/stl_algo.h:4212: error: no match for
'operator<' in
'(&__first2)->std::_Rb_tree_const_iterator<_Tp>::operator* [with _Tp =
TAnnotation]() <
(&__first1)->std::_Rb_tree_const_iterator<_Tp>::operator* [with _Tp =
TAnnotation]()'
Please, could you help me to resolve the problem?

Thanks in advance,
Giulio

Sep 20 '05 #1
1 1649
Giulio Veronesi wrote:

Hi,

Let us consider the following code fragment:

struct TAnnotation {
int x, y;

};

struct TAnnotationLT
{
bool operator()(const TAnnotation& a1, const TAnnotation& a2) const {
return ( (a1.x < a2.x) ||
( (a1.x == a2.x) && (a2.y < a2.y) ) );
}
This predicate is flawed. It contains a typo
Please, could you help me to resolve the problem?


http://souptonuts.sourceforge.net/co...ection.cc.html
--
Karl Heinz Buchegger
kb******@gascad.at
Sep 20 '05 #2

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

Similar topics

3
by: Mickel Grönroos | last post by:
Hi! Are there any standard list methods for getting the intersection and difference of two lists? (The union is easy ("list1.extend(list2)"), unless you want it to contain unique values.) ...
5
by: Antoine Logean | last post by:
Hi, What is the easiest way to get the intersection of two strings in python (a kind a "and" operator) ? ex: string_1 =...
17
by: Gordon Williams | last post by:
Hi, I have to lists that I need to find the common numbers (2nd rounded to nearest integral) and I am wondering if there is a more efficient way of doing it. >>> a= >>> b= >>> ...
3
by: Alain Frisch | last post by:
Hello, The following rule in the XML Schema spec, section "Schema Component Constraint: Attribute Wildcard Intersection" seems strange to me: ======================================= 3 If...
4
by: Sebastian Cohen S | last post by:
Hello, I am new to SQL and currently using Access 2003 and need a little help on the following. I have two queries each contains one column formed with a string that is very similar (only...
6
by: kimos | last post by:
hi all, how to calculate the intersection of 2 rectangle a rectangle is the following: Rectangle makeRectangle (Point lowerLeft, Point upperRight) { Rectangle r;
3
by: cai_rongxi | last post by:
Hi, Can some body share the code to find the intersection of two rectangles? Thanks in advance
2
by: mkppk | last post by:
I have kind of strange change I'd like to make to the sets.Set() intersection() method.. Normally, intersection would return items in both s1 and s2 like with something like this: ...
11
by: Prateek | last post by:
I have 3 variable length lists of sets. I need to find the common elements in each list (across sets) really really quickly. Here is some sample code: # Doesn't make sense to union the sets -...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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...
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...

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.