« first day (706 days earlier)      last day (4467 days later) » 

Xeo
Xeo
22:00
@sehe another non-trivial implementation thing is using empty arrays at the end if you get a push_front and vice versa
which took STL a few tries to get right, as I remember him saying.
That's good info /cc @CaptainGiraffe
@sehe That's actually an argument for me just not bothering with deque during lectures
I really want to though.
Xeo
Xeo
Of course you could deallocate your empty arrays all the time and just allocate new ones when you need them, but I think you'd violate a few complexity guarantees of the standard with that.
This is turning into the same Q I had about 3*N for the heapify condition =)
Xeo
Xeo
A better option might even be shifting your empty arrays to the front if you get a push_front, which would be O(1) if you use a linked list of arrays
22:04
@Xeo can't use a linked list, since you need O(1) lookup
Everything needs to be O(1)
Xeo
Xeo
@MooingDuck Have a seperate std::vector<std::list<T>::iterator>
well, amortized
Xeo
Xeo
@CaptainGiraffe amortized
@Xeo but then you have to insert into that iterator instead, which doesn't save you any complexity
22:05
@Xeo You drink 1234 beers and lets see how you spell.
Actaully, I still dont' understand how the deque gets O(1) push_back. I think MSVC violates that.
Xeo
Xeo
That was certainly not about spelling...
@MooingDuck Nope
array of fixed width buffers
@Xeo Beers?
Xeo
Xeo
@CaptainGiraffe Accumulated != amortized
It's not a question of spelling
@Xeo takes O(N) to insert a new buffer in the... oh wait, not if it keeps extra space on both ends, like a vector does on the back. I get it.
22:07
I seen you guys can manage this :)
I'm heading to bed then
@Xeo No? Please forgive me.
Night all
Xeo
Xeo
night
@MooingDuck amortized O(1) :)
Essentially, if you reuse empty buffers at the end for front insertion, you can just grow like a vector
But yes, deque is a mindfuck container
@Xeo I keep getting it, then getting confused, then getting it again, over and over.
Xeo
Xeo
Had that too at first
22:10
My club uses the ++ symbol. Are you with me?
Just don't tell Tony
Xeo
Xeo
@CaptainGiraffe Those are two vector arrows pointing at your eyes
Xeo
Xeo
22:24
I'm gonna hit the sack too, g'night to everyone who's left
everybody having fun?
I'm having trouble...
@Bane sad
Well, you could help :3
22:29
@Bane not if you don't say what you're having trouble with
`public:`
``
`Vector2 position (0, 0);`

This makes g++ report some errors, mainly "expected identifier before numeric constant"...
Why is that?
@Bane is that the first error?
Yes, just a sec
"error: expected ‘,’ or ‘...’ before numeric constant"

Those two happen on the same line in an .hpp file...
wait, that's not a valid syntax
you can't initialize a member like that, you initialize members in a constructor.
Yes, this is not valid. What do you intend to declare? Data member or function member?
22:32
Well, I wanted to declare a data member...
Then it should be Vector2 position;
public:
    Vector2 position;
If you are using C++11 you can attempt Vector2 position { 0, 0 } or Vector2 position = { 0, 0 };.
So I can't pass any arguments? Welp, I guess I'll just have to deal with it.
@LucDanton thank you, I will try.
@Bane you don't pass arguments, because that's not a function. It's not code that gets executed, it's merely a map of what goes where. You give it arguments in the constructor of the class.
22:35
@MooingDuck Kay, I guess I have to add the default constructor to my Vector2 class then...
@Bane no, you don't. That bit doesn't construct anything, it's merely telling the compiler what goes where.
An alternative is to make sure Vector2 has sensible semantics for default construction.
It's not always possible though.
@Bane you construct the Vector2 class in the constructor of whatever owns it.
struct thingy {
    Vector2 position;

    thingy(int first, int second) //thingy constructor
        :position(first, second) //construct the Vector2
    {}
};
So no neat deque implementation here either?
Oh, OK.
(Do you mean: {:position...}?)
22:38
@Bane The constructor arguments of position can be passed by the constructor initialization list of the "host" class. E.g. class MyClass { MyClass() : position(0, 0) {} }; (See @MooingDuck's code.)
@Chimera didn't know you were up for C# questions now :)
@sehe I've dabbled a bit with C#. Wrote one application for my job.
A good book could be helpful if you don't know yet how to write a constructor.
@Chimera you'd have to agree that Linq-to-XML beats XML readers. I'm pretty positive that performance will suck, compared with the XSLT approach
22:39
@sehe Skeet ripped me a new one huh?
@sehe XSLT performance is sucky by default
@Chimera From what I can still see, he has a point. I'm not used to seeing him attack anything at all, really
@sehe Yeah, I modified my answer. It does feel like he attacked me a bit harshly though.
link link link please
I think so too. It's just that we get a lot of link posters.
1
A: Parsing XElement

seheI came up with this: using System.Collections.Generic; using System.Linq; using System.Xml.Linq; using System.Xml.XPath; using System.IO; using System; public class Program { public static void Main(string[] args) { using (var fs = new StreamReader("./test.xml")) { ...

22:41
@CaptainGiraffe heh, I'd just read it. I just looked at his "recent activity", and it's at the top of the list.
@Chimera And... "he asked for general information" is not really an excuse, since that is nowhere near a proper SO question. It's hard to argue that you should answer the part of the question that sucked, in a way
@sehe That's why I posted some code that was an example of how to apply the techniques, then of course he rips me for not solving the exact problem.
That's the problem with the question, indeed
Yay, it works now. Thank you all!
Lets try and get Jon's answer a tad downvoted, just for fun?
22:43
@CaptainGiraffe I upvoted him, but I'm pretty pissed at how he ripped me apart.
Well unclick =) Jon Skeet Is still Skeet
@sehe Your answer is very good though.
Yes it is as good as Skeets, if not better
@Chimera Thanks :) Courtesy to Vim + mono on my linux box. I had to google for XPathSelectElements (and which namespace that lived in...)
That's why @sehe got my vote and Skeet didn't.
22:46
Jeebies!
So now we need reddit or twitter to upvote sehe.
thanks to whomever upvoted my lacking answer.
Oh sweet. I didn't know about conversion operators on XElements :) +1 — sehe 8 secs ago
Anyways, really off to bed. I got a bit sidetracked there.
22:51
I'm gonna call my hooker mama.
@sehe night
0
Q: Creating a copy of the object for multiple comparison is a good practice?

Viniyo ShoutaSuppose multiple comparations are required at once: enum usermode { active, standingby, inactive, dead, // many other modes.... }; class A { public: usermode mode; }; function inherited pointer to class A (ptr points to A) Method A: if( ptr->mode == active || ptr-&...

Talk about premature optimization!
Is anybody else's chat, especially the gravatars, screwing up?
nope
maybe that OP should make the enum's values multiples of two and just check against a mask? lol
@Chimera Not a bad idea, you should post that (maybe as a comment)
23:07
@Prætorian I might, actually I meant powers of two, not multiples of two..
@Chimera I read your earlier sentence as powers of two, not multiples of two :)
Often code like this is organised to exploit bit flags where you can test multiple modes with a single comparison. Similarly, you can arrange your enums in groups that need to be tested together (if it makes sense to do so) and compare with >= and/or <=. — paddy 13 mins ago
Hm, my accept rate is only 95%. Oh well :(
@MooingDuck See, somebody was reading my mind. :-)
23:23
waaaaiiiiiiiiit.... you cant bind a numeric literal to a const int& can you?
what the heck? Now my accept rate is 100%? It must round to the nearest 5% or something. Interesting.
or maybe it only counts answers with questions
@MooingDuck You can.
@LucDanton oh. yeah, I tested. You can
@LucDanton unrelated: just accepted your answer from forever ago, because I confirmed it does solve the issue with the two compilers I'm not using, and the other answer is... short.
I guess I didn't really have to tell you that since I also commented. Related: doing too many things at once is bad
23:45
@MooingDuck Your accept rate isn't affected by questions without answers.
@Rapptz noted. I might even remember.
@MooingDuck When I went to check your user profile I saw your conversation with Mohammed and now I feel like dual booting Ubuntu.
user1182183
@LucDanton Lol I'm the worst programmer ever (If I may call myself a programmer) and even I know how to write a constructor XD
hmm, Pandora won't let me un-thumbs-up except by giving it a thumbs-down. :(
Just gotta live with it.

« first day (706 days earlier)      last day (4467 days later) »