473,626 Members | 3,152 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

creation of a set of segments, please help

Hello everybody,

I have an interesting problem for which I still don't have a solution.
Imagine that you're working with points in two-dimesional space, so
the point class should be (simplifying):

class Point {

double x_,y_;

public:

Point(double x, double y) : x_(x), y_(y) {}
// other constructors and member functions
};

Now, imagine that you're also working with segments in 2D. A segment
consists of its endpoints:

class Segment {

Point source_, target_;
public:
Segment(const Point& s, const Point& t) : source_(s), target_(t)
{}
// other constructors and member functions
};
Now, I want to enforce that if I have points P1, P2, the segment P1-P2
is the same as the segment P2-P1. That is, the orientation of the
segment doesn't matter so as long as the endpoints are the same, the
segments are equal. This could be enforced by operator== in the
Segment class:

bool Segment::operat or==(const Segment& s)
{ return ((source_ == s.source_ && target_ == s.target_) || (target_
== s.source_ && source_ == s.target_)); }
Now, I would like to create a set of segments. Of course, the segment
does not have to have duplicates. However, sets are defined by using
operator< which is not defined here.

So the question is, how do I create a std::set of segments? Any ideas?
I could just write operator< so that it compares the smaller point
from both segments, but I thought that someone could have a better
solution.

Thank you all,

aa
Nov 13 '08 #1
0 1217

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

Similar topics

3
1198
by: Bernie Yaeger | last post by:
I'm trying to create a custom control that has 2 listviews, in view smallicon. I'm using these with code that makes them drag/drop controls, so what I am after is a control that does drag/drop automatically between these 2 listviews. However, I'm running into difficulty - when I add the control to a form, I have no way of adding items to listview1, since the custom control is not one listview, but rather two. I've used inherits...
8
2735
by: Ankit Aneja | last post by:
Hi I have made a windows service in C#.Net Now I want to create a setup of this service http://www.codeproject.com/dotnet/simplewindowsservice.asp I read this article Now my service is also using com dll I also want that dll to be registered on server(or computer) on which that service will be installed How can i do that.I am using visual studio.net 2003
2
1256
by: Garry Jones | last post by:
I have several seperate individual php segment which make up my website. To check what each segment actuallt displays I am linking my css style to each and every segment in a wysiwyg program. This results in a website with the same css file being called about 20 times. Of course I can delete all but one of these "link css rows" and then add them again as and when a segment needs to be edited. This seems to be a round about way of doing...
8
2621
by: karthik.infoguy | last post by:
Any one just let me know what are the different segments in a compiler and what data are stored in different segments????
5
1486
by: pavi | last post by:
Hi, I want to understand how the C's executable a.out is organised into segments. Which segments the varibles are put into according to their declarations. which Linux commands are used to check these details. Kindly anyone suggest any books or documents or link which contains details of the above. Regards, Praveen Kumar A.S
1
9647
by: phantom2850 | last post by:
hello friends, I recently attended 3 interviews, all three had similar questions... Where is const stored? what are diff segments? what is heap? where is it on RAM/ROM? what is stored in stack? what is relation b/w Segments and RAM/ROM/FLASH Can someone suggest me some tutorial for this?
7
2114
by: kr | last post by:
Hi All, Suppose I consider a sample program as given below:- #include<stdio.h> #include<stdlib.h> int i; int main() { char *test(int i); char *tmp = NULL;
2
4021
by: =?Utf-8?B?am9obnByZW1p?= | last post by:
Hi there, I have a web app that adds user into w2k3 server and adds it to the administrator group. The code snippet is something like this: try { DirectoryEntry AD = new DirectoryEntry("WinNT://" + in0.IPAddress + ",computer", in1.userName, decryptData(in1.password), AuthenticationTypes.Secure); // Create super user
4
1593
by: timmg | last post by:
I have an application were users evaluate records and based on the amount of money involved answer between 17 and a 120 questions on one of three response forms. I have a master list of question in one table and another that links the subset of questions to the particular form. When the user gets ready to answer the questions the app appends the questions to the answer table - all of which makes it easy to answer the questions within a...
0
8268
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8202
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8707
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8366
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7199
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5575
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4202
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1812
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1512
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.