non-sorting std::set ?

Discussion in 'C++' started by Gernot Frisch, Apr 14, 2005.

  1. er... I need a class that keeps the order of the elements, but does
    not allow duplicates to be inserted.


    --
    -Gernot
    int main(int argc, char** argv) {printf
    ("%silto%c%cf%cgl%ssic%ccom%c", "ma", 58, 'g', 64, "ba", 46, 10);}
    Gernot Frisch, Apr 14, 2005
    #1
    1. Advertising

  2. Gernot Frisch

    Jeff Flinn Guest

    Jeff Flinn, Apr 14, 2005
    #2
    1. Advertising

  3. Gernot Frisch

    Mike Wahler Guest

    "Gernot Frisch" <> wrote in message
    news:...
    > er... I need a class that keeps the order of the elements, but does not
    > allow duplicates to be inserted.


    That's what 'std::set' does ('std::multiset' allows
    duplicates). BTW tyur question does not correspond to your
    subject line: "non-sorting std::set".

    -Mike
    Mike Wahler, Apr 17, 2005
    #3
  4. "Mike Wahler" <> schrieb im Newsbeitrag
    news:t4w8e.9755$...
    >
    > "Gernot Frisch" <> wrote in message
    > news:...
    >> er... I need a class that keeps the order of the elements, but does
    >> not allow duplicates to be inserted.

    >
    > That's what 'std::set' does ('std::multiset' allows
    > duplicates). BTW tyur question does not correspond to your
    > subject line: "non-sorting std::set".


    Er... I thought std::set (and atd::map) will sort the data, so finding
    if the item already is in the list works fater. Also, what would you
    be able to provide a "sort struct" as 3rd constructor parameter for?
    -Gernot
    Gernot Frisch, Apr 18, 2005
    #4
  5. Gernot Frisch

    Mike Wahler Guest

    "Gernot Frisch" <> wrote in message
    news:...
    >
    > "Mike Wahler" <> schrieb im Newsbeitrag
    > news:t4w8e.9755$...
    >>
    >> "Gernot Frisch" <> wrote in message
    >> news:...
    >>> er... I need a class that keeps the order of the elements, but does not
    >>> allow duplicates to be inserted.

    >>
    >> That's what 'std::set' does ('std::multiset' allows
    >> duplicates). BTW tyur question does not correspond to your
    >> subject line: "non-sorting std::set".

    >
    > Er... I thought std::set (and atd::map) will sort the data,


    Correct. I thought that's what you meant by 'keeps the order of the
    elements'.

    > so finding if the item already is in the list works fater.


    Faster than what?

    >Also, what would you be able to provide a "sort struct" as 3rd constructor
    >parameter for?


    I presume you're talking about the 'predicate' argument. This
    is for you to define your own meaning to ordering (specifically
    the meaning of 'less than').

    -Mike
    Mike Wahler, Apr 20, 2005
    #5
    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.

Share This Page