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

  • SEARCH
  • Home
  • 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 6229227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:31:52+00:00 2026-05-24T09:31:52+00:00

I am having problems with sets all day. Some I can solve, others not.

  • 0

I am having problems with sets all day. Some I can solve, others not. This one is bugging me since the morning, and I have run out of patience. Please help, mighty stackoverflow!

So, I have a set which contains a custom object of mine, its called “vect” and is based on eigen::matrix. That means, I get values from vects with the [] operator.

set<vect*> *tvps=getTheSet();

for (set<vect*>::iterator iter = tvps->begin(); iter != tvps->end(); ++iter)
{
    vect v= **iter;   // Don't really know why two asterisks,
                      // but my compiler would complain
    int x=v[0];
    int y=v[1];
    doStuffWith( v[0],v[1]);

}

Now, this will compile and run and everything. But the values I get from the iterator are 30% trash:

x: 110   y: 90
x: 230   y: 130
x: 250   y: 100
x: 230   y: 130
x: 110   y: 290
x: 140   y: 260
x: 180   y: 280
x: 150   y: 210
x: -2147483648   y: 0
x: 180   y: 280
x: 170   y: 230
x: 240   y: 270
x: -2147483648   y: 0
x: -429917536   y: 0
x: 0   y: -2147483648

I checked at the point where the set was put together which values where put in. Only the ones between 10 and 300.. as intended. How comes I find others in it? Did I screw up with the iterator?

  • 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-05-24T09:31:54+00:00Added an answer on May 24, 2026 at 9:31 am

    There are a few possibilities as to why this is happening to you:

    • Are you reusing the set. If yes, do you clear() it between reuses ?
    • You are storing pointers to vectors in the set, are you changing the vectors inside the set ?

    Perhaps you want to store the pointer to the vector because otherwise the compiler gives you an error due to the fact that it doesn’t know how to compare two vectors. Why don’t you try to implement the comparison function and store vectors directly ? that way your work would be a lot easier and much less error prone.

    Also the problem you have now is that the elements in the set don’t seem to be ordered.. in fact they are ordered by the pointer value, and not by X and Y (and I suppose that’s what you want)

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

Sidebar

Related Questions

So, I was having all kinds of trouble with CRUD operations on sets of
I'm having something of a dilemma and would appreciate some input. I have this
I prefer to have one workspace and put all my projects into this one
I'm using Google Maps with Flex 3. I'm having problems clearing markers. Users can
I've been having some problems with using BerkeleyDB. I have multiple instances of the
I'm having this argument about using Cursors in TSQL recently... First of all, I'm
So I'm having problems releasing some view controllers. In essence the dealloc for the
Having problems with a small awk script, Im trying to choose the newest of
Having problems iterating. Problem has to do with const correctness, I think. I assume
Im having problems displaying records to my view when passing viewdata to a user

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.