Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7902499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:30:34+00:00 2026-06-03T09:30:34+00:00

I need a solution for a specific situation. I have an algorithm which basically

  • 0

I need a solution for a specific situation. I have an algorithm which basically works on line segments. I only know the line segments end and start points. (Points have 2 coordinates x,y. These are pixel points on image. Also I know the sizes of image.) I want to examine these line segments and do something on them. However, I also need to keep track of examined line segments so that, I wont examine the same line segment again. I’m using C++, so I want to use stl set container.

My question is how can I store these line segments according to their end and start points? I need to produce unique number for end and start points. (Also I’m open for any other advice other than using stl set :))

One possible solution is that I produced index numbers for these two pixels by: (y*image->Witdh) + x. Then I get two index numbers (by the way they are integers.) Then I concatenate these numbers by: (indexStart << 32) + indexEnd.(I get double). Now I have unique number and I can easily store in set. BUT the problem is while on my search, once a start point of a line segment can be the end point of the same line segment. If I came across the same line segment from endpoint then the concatenated line segments unique number become (indexEnd << 32) + indexStart. Then I will add the same line segment to the my set container which I need to avoid.

Thanks for any advice.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T09:30:36+00:00Added an answer on June 3, 2026 at 9:30 am

    You can keep your solution or use an operator<. Your has the advantage that switching to some hashset implementation is trivial, the other one should be better practice overall (much easier to understand, probably faster, can be used with 64bit coordinates, etc).

    Just solve the problem you describe (you’ll have to do this for both apporaches) by not distinguishingstart and end but lower and upper coordinates. Always using the smaller coordinate in the same place is an easy fix to getting false-positive different segments when you discover them the other way round

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a big solution containing that much projects..i need to find a specific
I have a situation in which i need a reference to the very next
I have a situation where I want to use several server side controls, which
I have a VB6 application which works with datetime values in SQL Server (which
I have a special situation where I need to query a service to get
In my code, I have a situation where I need to copy data from
I need help on a specific task : I have a ListView in my
I need a solution to embed a pdf inside a flash screen i.e. want
I need a solution for caching PHP info on a dynamic page AND include
Simple question: I need a solution so that I can find, lets say names,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.