Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > BOOK: Professional C++
Password Reminder
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional C++
This is the forum to discuss the Wrox book Professional C++ by Nicholas A. Solter, Scott J. Kleper; ISBN: 9780764574849
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional C++ section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Display Modes
  #1 (permalink)  
Old May 25th, 2006, 10:21 PM
Registered User
Join Date: Oct 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Question on Hashmap


First, I would like to express my appreciation
for the contents of chapter 23 (it's great!)

I would like to know what's the proper
way to instantiate a hashmap, where the
Compare parameter should maintain its
default value, but the Hash function is
other than DefaultHash<Key>

template<typename Key, typename T, typename Compare = std::equal_to<Key>, typename Hash = DefaultHash<Key> >
    class hashmap { //... };

I only need the Hash parameter changed.

Must I do something like:

hashmap<int, string, std::equal_to<int>, MidSquare<int> > hash1?

Second question: Since "count" is only used to check whether an
element exists, would there be any consequence in using bool as
a return type instead of size_type for the count method?

Thank you,
A. Alothman

  #2 (permalink)  
Old September 3rd, 2006, 02:13 AM
Authorized User
Join Date: Oct 2004
Location: San Francisco, CA, .
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts

Unfortunately, you'd have to specify the first three arguments to use a non-default value for the fourth. The STL classes have this same drawback -- you'll sometimes find yourself looking up and providing the default for one argument just so that you can change the following one.


Scott J. Kleper
Author, "Professional C++"
(Wrox, 2005)

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to loop through a HashMap in XSL? sunilnk XSLT 6 April 10th, 2017 04:09 AM
jsp need to store data in hashtable or hashmap kotaiah JSP Basics 0 October 14th, 2006 01:48 AM
To sort a hashmap using its keys and/or values Mr. Ram Java Basics 1 June 1st, 2006 11:19 PM
HashMap mudit_12 Intro Programming 0 March 2nd, 2005 11:46 PM
HashMap freezotic BOOK: Beginning Java 2 6 March 26th, 2004 03:27 PM

All times are GMT -4. The time now is 02:47 PM.

Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.