STL algorithm problem vector<vector<double> > and find

Discussion in 'C++' started by Dennis, Jun 7, 2004.

  1. Dennis

    Dennis Guest

    Hi

    I'm trying to implement a vector of vectors where find can be used to
    find a vector<double> in the vectors of vectors, that is hard to
    understand i guess.
    What I mean is that I got a vector foo containing vectors of the size
    3. I then want to compare a vector<double> of size 3 (coord) with foo to find
    a sequence of elements in foo that equals coord. However, when I try
    this it returns when just one of the element of coord equals one
    element in foo.

    I just can't figure this out, is it possible to do this in any way ?
    Example of what I want:

    vector<double> coord(3,1);
    vector<vector<double> > foo;
    //fill foo with coordinates .......
    vector<vector<double> >::iterator findIte =
    find(foo.begin(),foo.end(),coord);


    an example of foo:
    1 1 0
    0 0 1
    0 0 2
    1 1 1 <------- coord = (1 1 1), this is where findIte should point
    1 0 1
    1 0 0

    I hope it makes a little sense what i'm trying to do.

    Best Regards

    Dennis
     
    Dennis, Jun 7, 2004
    #1
    1. Advertising

  2. Dennis

    Dennis Guest

    Dennis <> writes:

    > I hope it makes a little sense what i'm trying to do.
    >


    My mistake it was just my f.... debug code that didn't work as
    expected, everything is as it should be.

    Dennis
     
    Dennis, Jun 7, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sydex
    Replies:
    12
    Views:
    6,646
    Victor Bazarov
    Feb 17, 2005
  2. Ingo Nolden
    Replies:
    15
    Views:
    1,548
    Jerry Coffin
    Apr 30, 2005
  3. cayblood
    Replies:
    5
    Views:
    6,282
    Calum Grant
    Nov 3, 2005
  4. Replies:
    8
    Views:
    1,998
    Csaba
    Feb 18, 2006
  5. J.M.
    Replies:
    5
    Views:
    809
Loading...

Share This Page