Home > Need Help > NEED HELP FAST For Unfair C++ Assignment

NEED HELP FAST For Unfair C++ Assignment

The use of the value_type has advantages too: you don't need to know the mapped type or key type so is useful with template programming. Keep in mind that there are cases when the two are not similar. try to measure the size in a loop like that. Posts: 5491 Joined: Thu May 03, 2007 7:32 pm UTC Contact: Contact Hammer Website Re: NEED HELP FAST for unfair C++ assignment Quote Postby Hammer » Sun Nov 04, 2007 2:08 http://diskpocalypse.com/need-help/need-help-fast-pls-ty.php

I am a (nearly) straight 'A' university student, who despite having followed my curriculum exactly as intended and meeting all prerequisites, have found myself forced into a class with fairly moderate Top GameMaster13 Posts: 5 Joined: Fri Nov 02, 2007 10:32 pm UTC Re: NEED HELP FAST for unfair C++ assignment Quote Postby GameMaster13 » Sat Nov 03, 2007 12:55 am UTC If in doubt - profile. If you read the Rules thread, you will see that you should have at least 10 posts before posting links. "What's wrong with you mathematicians?

Oh, and are we even supposed to solve homework? Powered by vBulletin Copyright ©2000 - 2017, Jelsoft Enterprises Ltd. What initially threw me off was that the Insert() function (within the lab instructions) had no empty lines between the brackets, while the Union() and Intersection() functions DID.. Find out why these languages are the foundation on which other languages are built.

No-one said you're not allowed to mix pointers and std::strings. This led me to believe it implied that the Insert() function needed no modification, only Union() and Intersection()... How is the intersection operation defined on normal sets in mathematics? insert is second (but will be extremely close). [] is least efficient. [], if there is no object there, trivial constructs one.

have the end-effect of "doing nothing") without performing as explicit check for self-assignment. Then you'll have an accurate comparison. It is a very rare situation in which updating a will invalidate a cache line and incur a performance hit. Sorry if I stepped over the line.

a "nearly" A straight student with a profile such as your makes me want to cry. What was the tallest structure built in Middle-earth? The search function was already written for you, so all you have to do is something like this: Code: void Set::Insert(int n) { if(this->Search(n) >= 0) return; this->InsertFront(n); } Now that share|improve this answer answered Jan 8 '13 at 15:24 Jerry Coffin 330k31369774 add a comment| up vote 1 down vote 1) may be slightly slower than the other methods because std::map::operator[]

Example 1: A function with two different responsibilities is difficult to make exception-safe. Some cpu support single instruction test and set. x=0; --OR-- x^=x; Taylor c++ c performance variable-assignment xor share|improve this question edited Apr 4 '13 at 16:42 Mysticial 299k35250271 asked Apr 4 '13 at 16:40 tejloro 553 closed as too But, again, you should profile it.

Oh and by the way, bitwise xorring an uninitialized integer by itself is undefined behavior and a good compiler should optimize out the entire thing. his comment is here This makes it easy to return a dangling reference--the const reference binds to a temporary object. more stack exchange communities company blog Stack Exchange Inbox Reputation and Badges sign up log in tour help Tour Start here for a quick overview of the site Help Center Detailed It's totally reasonable to assume that many STL algorithms (partitioning, sorting and such) will do self-assignments on the elements. –fredoverflow Aug 18 '12 at 7:59 | show 1 more comment Your

So now, even a humble assignment of one std::string to another, (or equivalently, passing a std::string as a parameter to a function), takes about 400 machine code instructions instead of the Why do many sites leave half of each webpage empty? Then a = SOMEVALUE; sets a to 0, and if (a != SOMEVALUE) a = SOMEVALUE doesn't. this contact form It will depend entirely on the underlying hardware and the instruction set it supports (assuming the compiler uses the hardware optimally).

Top EvanED Posts: 4303 Joined: Mon Aug 07, 2006 6:28 am UTC Location: Madison, WI Contact: Contact EvanED AOL Re: NEED HELP FAST for unfair C++ assignment Quote Postby EvanED » The time now is 02:26 AM. Reallocation will also avoid making copies, but will move elements where appropriate to their new places.

How to avoid a useless return in a Java method What point on the main land of The Netherlands is furthest away from any buildings?

Join them; it only takes a minute: Sign up C/C++: is it faster to assign a 0 to an unsigned long variable or to xor the variable with itself? [closed] up You may have to register before you can post: click the register link above to proceed. I'd be quite surprised to see a real difference from this though, except (possibly) if you were careful to ensure that the compiler did absolutely no optimization (especially inlining) at all. I mean..

For ref-counted objects, you don't want destructors being called when you don't know about them. –cjcurrie Jan 12 '13 at 13:54 +1 one of only two correct answers. –Cheers Can stealth be consistently successful? Eg.: std::string a = "String a" std::string b = "String b" // Use a.swap(b); // Instead of std::string tmp = a; a = b; b = tmp; And a final note. navigate here Do not create unnesessary objects.

Similar Threads - NEED HELP FAST Help needed to solve LMC programming with the following!!! Locking objects against concurrent access is still needed today. By the way, the ' this->ClearAll(); ' statement that you seemed to indicate was necessary was not needed. Some CPU instruction sets support a test and set in a single instruction. –Loki Astari Jul 19 '12 at 15:07 While what you say is correct, the point of

I've seen a fair bit of code that returns void from copy assignment overloads, and I can't recall when that caused a serious problem. This means that they are equally fast. Basically, I am stuck on the the Union and Intersection portions, as my course materials have no reference for how to do this whatsoever.. up vote 19 down vote favorite 4 In Herb Sutter's book Exceptional C++ (1999), he has words in item 10's solution: "Exception-unsafe" and "poor design" go hand in hand.

Problem is, I don't really have any idea what that modification would be, though I suspect the " if (front == NULL) { " code block "...Yeah, I think that my More programs worked, but they were all slower. Just more buggy. Could a creature have eyes that change color based on their mood?

Please think before you speak of that which you know little about.