Help with Cryptic C++ code

Programming, for all ages and all languages.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Help with Cryptic C++ code

Post by Solar »

BI approximates his mood using a Lagrange algorithm. Sometimes he's a jolly chap to have around, sometimes he's a bit testy. ;D
Every good solution is obvious once you've found it.
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Re:Help with Cryptic C++ code

Post by distantvoices »

@solar: yeah, that's a taylor series with a lagrange remainder member (in german it's the lagrang'sches Restglied)*gg*

@Neo: Slow down, breathe and relax: I have been talking to solar about an event, then you ask anyone but me what the heck I'm talking about and then you wonder why I'm a bit testy about that? Oh, come on, lad.
Err.. ??
That was to beyond_infinity's post.
That#s what it is about, fyi ;-)

Now, I suppose we'll have a coffee and give it a rest, ok?
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
User avatar
Neo
Member
Member
Posts: 842
Joined: Wed Oct 18, 2006 9:01 am

Re:Help with Cryptic C++ code

Post by Neo »

beyond infinity wrote: @Neo: Slow down, breathe and relax:
Think you need to do that bro.
I have been talking to solar about an event, then you ask anyone but me what the heck I'm talking about and then you wonder why I'm a bit testy about that? Oh, come on, lad.
The first post from you in this thread (which is about C++ multimaps BTW) is the one where you where talk about breakpoint 2006, which confused me. Hence the "Err..??"
And then you ask me if I have a problem with what you are posting? Funny.
Now, I suppose we'll have a coffee and give it a rest, ok?
Sure.
Only Human
User avatar
Neo
Member
Member
Posts: 842
Joined: Wed Oct 18, 2006 9:01 am

Re:Help with Cryptic C++ code

Post by Neo »

Solar wrote: When constructing a multimap, you can pass to the constructor a function object (predicate) that does the ordering. By default, this is [tt]less[/tt], meaning that, if you get two elements X, Y with X->first == Y->first, you will get one after another, but the exact order is unspecified (as neither is "less" than the other). This is called "strict weak ordering".
Just wanted to confirm this. If I have a [font=Courier New]multimap<priority, Struct1>[/font]
and I insert items like
[font=Courier New]<1,struct_var1>
<0,struct_var2>
<1,struct_var3>
<2,struct_var4>
<0,struct_var5>[/font]
and when I traverse through this multimap will I get the elements in this order
struct_var2
struct_var5
struct_var1
struct_var3
struct_var4
I did get this with gcc (is it the same with the others?)
Only Human
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Help with Cryptic C++ code

Post by Solar »

Neo wrote: ...when I traverse through this multimap will I get the elements in this order...
No.

You will get struct_var2 and struct_var5 before you get the others, and you will get struct_var4 last. But whether you get struct_var2 before or after struct_var5 is not defined, and neither is whether you get struct_var1 before or after struct_var3.

Actually, the sequence could be different the very next time you iterate through the map. Edit: Not really sure here, but better safe than sorry.

It is very dangerous to go "trial and error" in these things. The next version of GCC might change this behaviour, and silently (i.e., without mentioning the fact anywhere), because the standard does not guarantee a strong ordering here.
Every good solution is obvious once you've found it.
User avatar
Neo
Member
Member
Posts: 842
Joined: Wed Oct 18, 2006 9:01 am

Re:Help with Cryptic C++ code

Post by Neo »

Hmmm........ ok. Should keep that in mind then.
@Solar: Thanks.
Only Human
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Help with Cryptic C++ code

Post by Candy »

Neo wrote: Hmmm........ ok. Should keep that in mind then.
@Solar: Thanks.
The order probably is stable but unpredictable up-front. The multimap probably uses a set for each key, with a tree or a hash implementation behind it.
Post Reply