Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

c++ Simple Class Question

Name: Anonymous 2007-06-27 0:40 ID:CjAL5fOI

I have a class called htable, when it reaches a certain size it will rehash itself. Heres the pseudo code:

/* Creates new table, and deletes old one. */
Htable Htable::htable_rehash(){
   make new Htable;
   add old values to new table;
        delete old table;
   return new Htable;
}

to call it I would say hashtable = hashtable .htable_rehash();

My question is this: do i need to free the memory in the old hash table in the class, or will it be deleted when i say table = table.rehash?

Name: Anonymous 2007-07-01 7:41 ID:7UC38q+h

>>42 That syntax is valid, what is your problem - never seen it before newbie?

>>43 Yes, in the ops it was a while loop - the purpose of the code was to demonstrate what real c++ could look like, I wasn't concerned about if it actually worked, if it doesn't any changes would be pretty minor.

Overall it's about 20 less lines than the ops, more readable and less error-prone. CODE IS NOT SHIT LOSERS.

If you think it is, rewrite the OPs insert function (in C++) and show me better.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List