Sort algorithm on vector of structures

Pages: 12
Think of threads, parallelism. Two threads execute simultaneously.
One is running a long sort, where essentially:
1
2
3
4
5
for ( /*...*/ ) {
  // ...
  // use global sortby
  // ...
}

The other thread changes the value of sortby while the first is still doing the sort.
Will the result of sort be what it should?

Threading done proper has to check and guard against such threats.
Which one is it if I may ask


Ah well, confessions ahead ...!


Actually, I found it quite acceptable for a C/C++ beginner (although I had programmed in Fortran for many years). The main downside is that it was published long before C++11, so obviously doesn't contain that material, and has only limited coverage of containers, algorithms and the standard template library. Hence my early posts in this forum were embarassingly naive. But, in my personal opinion, the book doesn't deserve the bad press thrown at it.

Nowadays, I occupy many train journeys with

which is a fantastic book. However, I would have been very hard-pressed to get into it as a beginner. He has written a more learning-type book for the latter, but I don't have a copy. (Plenty of the examples seem to come up on this forum, though, so other people obviously do.)
Last edited on
But, in my personal opinion, the book doesn't deserve the bad press thrown at it.

Actually the bad press really concerns the author. His early books were truly horrible and unfortunately many of his subsequent books were based on those early books. IMO his C++ books teach too many C constructs before getting to "real" C++.

Anything written by Schildt is garbage, and teaches you stuff you'll have to unlearn, and leaves out very important stuff you need to learn. The guy has no business near C or C++, but unfortunately he continues to sell a lot of books on the subject.

Here's a scathing (and still current) review by someone who matters: http://www.seebs.net/c/c_tcn4e.html

Throw that book out.
No matter: your link is actually about a different book, @Duthomas.

I'm referring to the C++ one, not the C version.
Last edited on
closed account (E0p9LyTq)
C++ and Schildt (with other books equally bad):
http://www.cs.technion.ac.il/users/yechiel/CS/BadBooksC+C++.html#SchildtAny

He really is to be avoided at all costs.
Last edited on
Think of threads, parallelism. Two threads execute simultaneously.
You're right, I didn't have multi-threading in mind, in which case it can indeed be quite problematic.

@lastchance
Thank you for the info, the last book you mentioned on c++11 looks interesting, I'll have a look into it!


Cheers!
Last edited on
Topic archived. No new replies allowed.
Pages: 12