Click here to Skip to main content
16,006,428 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
AnswerRe: WTL ? Pin
Steve S24-Oct-02 2:52
Steve S24-Oct-02 2:52 
GeneralRe: WTL ? Pin
puzzolino24-Oct-02 3:01
puzzolino24-Oct-02 3:01 
GeneralRe: WTL ? Pin
Paul M Watt24-Oct-02 5:09
mentorPaul M Watt24-Oct-02 5:09 
GeneralRe: WTL ? Pin
puzzolino24-Oct-02 5:30
puzzolino24-Oct-02 5:30 
Generalhash_map question Pin
User 988523-Oct-02 9:38
User 988523-Oct-02 9:38 
GeneralRe: hash_map question Pin
Tim Smith23-Oct-02 10:31
Tim Smith23-Oct-02 10:31 
GeneralRe: hash_map question Pin
User 988524-Oct-02 8:21
User 988524-Oct-02 8:21 
GeneralRe: hash_map question Pin
Tim Smith24-Oct-02 14:20
Tim Smith24-Oct-02 14:20 
Could you use STLPort? It is starting to sound like their hash_map might work for you.

Are you recreating the hash map a lot? If not, then the auto-rehashing of STLPort's hash map would be a good feature. (For my specific needs, this one feature was a performance bottle neck)

Also, collisions don't have to be a bad thing. One of my most common speed improvements (other than removing the sometimes counter productive rehashing) is to try to make key compares very fast. For string based key compares I don't use strcmp. I store the length of string as part of the key. Thus prior to doing the actual byte compare of the string, I would compare then lengths. If they don't match, then the keys don't equal. If they do match you can use memcmp instead of strcmp for even more performance. If your keys are much more complicated than a simple string, then you can also use the computed hash value as a quick test. The important thing is to try to have a simple value that can act as a quick test to weed out the most possible slow key compares. This quick test should also be well distributed within the hash table.

Unfortunately, that speed improvement won't work for Dink's system since they want > instead of ==. If you decide to implement your own (but I would try STLPort first), I wouldn't over design it. Try a simple hash chain for collisions. Try a simple hash with a fixed width and a good quality hash generator. If you hash generator is good enough, your hash table doesn't even need to be sized by a prime. But primes work great for hash values based on such things as addresses. Try to improve your equality key test so that it is very fast. That is one thing I like about rolling your own simple hash map, you have total control over it and can design it specifically to meet your needs. For example, in my hash table for an atom table, I have the string stored in the same memory block as the rest of the hash support structure (which also means I used... MALLOC, oh horrors). This helps to prevent the CPU and L2 memory cache from having to access a ton of diverse pages. In my compiler's symbol table, I ended up storing everything including the hash in one long buffer. This allow me to quickly remove all local variables defined in a scope "{}" by restoring the hash table starting points and the size of the symbol table. 33 integer values copied with memcpy and one or a thousand local scope variables are removed in a flash. It is examples like this why I always preach that when appropriate people should never fear writing their own containers.

Ok, I am stopping now. I am starting to ramble. Smile | :)


Tim Smith

I'm going to patent thought. I have yet to see any prior art.
GeneralRe: hash_map question Pin
Tim Smith24-Oct-02 14:29
Tim Smith24-Oct-02 14:29 
GeneralRe: hash_map question Pin
Tim Smith24-Oct-02 14:41
Tim Smith24-Oct-02 14:41 
GeneralRe: hash_map question Pin
User 988525-Oct-02 1:56
User 988525-Oct-02 1:56 
GeneralRe: hash_map question Pin
Joao Vaz25-Oct-02 6:10
Joao Vaz25-Oct-02 6:10 
GeneralRe: hash_map question Pin
Tim Smith25-Oct-02 7:16
Tim Smith25-Oct-02 7:16 
GeneralRe: hash_map question Pin
Joao Vaz25-Oct-02 7:48
Joao Vaz25-Oct-02 7:48 
GeneralRe: hash_map question Pin
Tim Smith25-Oct-02 8:38
Tim Smith25-Oct-02 8:38 
GeneralRe: hash_map question Pin
Joao Vaz25-Oct-02 8:56
Joao Vaz25-Oct-02 8:56 
GeneralRe: hash_map question Pin
User 988530-Oct-02 13:39
User 988530-Oct-02 13:39 
GeneralRe: hash_map question Pin
Tim Smith30-Oct-02 14:49
Tim Smith30-Oct-02 14:49 
GeneralRe: hash_map question Pin
User 988530-Oct-02 16:09
User 988530-Oct-02 16:09 
Generalxstring info Pin
Senkwe Chanda23-Oct-02 0:38
Senkwe Chanda23-Oct-02 0:38 
GeneralRe: xstring info Pin
Senkwe Chanda23-Oct-02 1:35
Senkwe Chanda23-Oct-02 1:35 
GeneralRe: xstring info Pin
Tim Smith23-Oct-02 2:38
Tim Smith23-Oct-02 2:38 
GeneralRe: xstring info Pin
ian mariano29-Oct-02 3:04
ian mariano29-Oct-02 3:04 
GeneralCOM EXE is not inheriting PATH environment variable from the calling process Pin
ksgopi22-Oct-02 16:07
ksgopi22-Oct-02 16:07 
QuestionMFC's CObject and CObList equivalents in ATL? Pin
LukeV22-Oct-02 5:40
LukeV22-Oct-02 5:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.