KBD

Keith Devens .com

Friday, January 9, 2009 Flag waving
I meant what I said, and I said what I meant. An elephant's faithful, one hundred percent! – Horton (Horton Hears a Who, Dr. Seuss)

Archive: July 24, 2003

← July 23, 2003July 25, 2003 →

Daily link icon Thursday, July 24, 2003

Mensa

Hey, I got into Mensa. That means I'm smart... psh. I heard a statistic that the average Mensan makes less than the average American. I wonder if that's true Smiley

vector resize() problems

My C++ code is just about done, except when I resize() a vector, my data is getting screwed up. Turns out there's this statement on page 456 in Stroustrup (special edition):

When a vector is resized to accomodate more (or fewer) elements, all of its elements may be moved to new locations. Consequently, it is a bad idea to keep pointers to elements in a vector that might be resized; after resize(), such pointers could point to deallocated memory. Instead, we can keep indices.

And that's exactly what I'm doing. Why would it deallocate existing elements on resize? That causes my objects to be destructed and all their data to be freed, so there's nothing to put in the new location. And what does he mean by "we can keep indices"? Indices to what? I thought a pointer was an index Smiley (to the place in memory where I'm keeping my object).

So... how do I do what I need to do?

Hmm... actually, I'm not keeping pointers in my vector... I'm keeping handles to objects. So the handle gets destructed and frees my memory, but if I keep pointers in there instead the pointers should just be copied, right? So now I have to rewrite all my vector code to use pointers to the handles to the objects? Grr! Smiley

Weblogs.com is VERY slow

New record for weblogs.com - and this at 6 in the morning. 215 seconds!

Finding Nemo again

I think I want to see Finding Nemo again. I just saw some clips of it on the news, and it's such a beautiful movie. If anyone's in the area who wants to come... Smiley

Finding Nemo!

Mr. T - Preacher Man!

I'm watching Mr. T preaching right now on TV. Yes, Mr. T. He's awesome.

← July 23, 2003July 25, 2003 →
January 2009
SunMonTueWedThuFriSat
 123
45678910
11121314151617
18192021222324
25262728293031



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 3 posts

Recent comments XML

The Elegant Universe

Well I have finally found the crazy​guy that preaches useless nonsence​in A...

Joseph Baxter: Jan 7, 11:07pm

I hate Norton Antivirus


SYMANTEC is very​cunning..
Symantec now have a​redeemable cash back offe...

CAN: Jan 4, 6:25pm

Spider solitaire

Hi everyone!

Glad to have found​this site.  I have enjoyed reading​the c...

flwrchld53: Jan 4, 5:30pm

Generated in about 0.056s.

(Used 7 db queries)

mobile phone