Click here to Skip to main content
15,914,820 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
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 
I did a performance analysis of my whole program and it turned out that hash_map was the least of my problems.

check this out
http://www.codeproject.com/script/comments/forums.asp?msg=323560&forumid=4486#xx323560xx


This is my hash_compare implementation. It works quite well. As you can see, I increased the starting bucket size to 512 and it works well. I am not at all concerned abut a little higher memory usage Big Grin | :-D

<code>// Template specialization for using DINKUMWARE STL hash_map classes
namespace std
{
	struct str_hash : public binary_function<size_t, char, size_t>
	{
		inline size_t operator() (const size_t hash, const char c)
		{
			return (hash<<5) + hash + c;
		}
	};

	template<> class hash_compare <string, less<string> >
	{
		less<string> comp;
		public:
			enum
			{						// parameters for hash table
				bucket_size = 4,	// 0 < bucket_size
				min_buckets = 512	// min_buckets = 2 ^^ N, 0 < N
			};	

		inline size_t operator()(const string& k) const
		{
			return accumulate(k.begin(), k.end(), 0, str_hash() );
		}

		inline bool operator()(const string& k1, const string& k2) const
		{
			return k1 > k2;
		}
	};
}</code> 


modified 29-Aug-18 21:01pm.

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 
AnswerRe: MFC's CObject and CObList equivalents in ATL? Pin
Anonymous24-Oct-02 6:27
Anonymous24-Oct-02 6:27 
GeneralHTML Source of MSHTML Pin
jajamal22-Oct-02 5:39
jajamal22-Oct-02 5:39 
GeneralRe: HTML Source of MSHTML Pin
Paul M Watt22-Oct-02 12:41
mentorPaul M Watt22-Oct-02 12:41 
GeneralRe: HTML Source of MSHTML Pin
jajamal22-Oct-02 22:50
jajamal22-Oct-02 22:50 
GeneralARRGHH!! MessageBox call from a dll Pin
Phil.Benson21-Oct-02 22:29
professionalPhil.Benson21-Oct-02 22:29 
GeneralATL & databases Pin
LukeV21-Oct-02 17:56
LukeV21-Oct-02 17:56 
GeneralRe: ATL & databases Pin
Vagif Abilov21-Oct-02 19:59
professionalVagif Abilov21-Oct-02 19:59 
GeneralRe: ATL & databases Pin
Jörgen Sigvardsson1-Nov-02 0:47
Jörgen Sigvardsson1-Nov-02 0:47 
Generaldate/time parsing and formatting (STL) Pin
SNagase21-Oct-02 9:54
SNagase21-Oct-02 9:54 

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.