Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Optimal std::map Key

58 views
Skip to first unread message

MikeCopeland

unread,
Apr 6, 2015, 6:35:05 PM4/6/15
to
I have an std::map with a key that's quite large. The key data is
comprised of numeric digits, so I can use either unsigned long or
basic::string as the key type. The data range isn't sparse (371920945,
387731336, 388604385, 392868398, etc.). My concern is that with such
a large key (as string type), would the map processing be significantly
more efficient if the type for the key is declared as "unsigned
long"...or does it not matter? TIA

---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com

Ian Collins

unread,
Apr 6, 2015, 6:45:28 PM4/6/15
to
MikeCopeland wrote:
> I have an std::map with a key that's quite large. The key data is
> comprised of numeric digits, so I can use either unsigned long or
> basic::string as the key type. The data range isn't sparse (371920945,
> 387731336, 388604385, 392868398, etc.). My concern is that with such
> a large key (as string type), would the map processing be significantly
> more efficient if the type for the key is declared as "unsigned
> long"...or does it not matter? TIA

Why would you represent a numeric key as a string?

--
Ian Collins
Message has been deleted

MikeCopeland

unread,
Apr 6, 2015, 11:02:28 PM4/6/15
to
In article <coggjr...@mid.individual.net>, ian-...@hotmail.com
says...
No choice: that's the data I'm presented from the client; 8<{{

Mr Flibble

unread,
Apr 8, 2015, 12:21:31 PM4/8/15
to
On 07/04/2015 04:02, MikeCopeland wrote:
> In article <coggjr...@mid.individual.net>, ian-...@hotmail.com
> says...
>>
>>> I have an std::map with a key that's quite large. The key data is
>>> comprised of numeric digits, so I can use either unsigned long or
>>> basic::string as the key type. The data range isn't sparse (371920945,
>>> 387731336, 388604385, 392868398, etc.). My concern is that with such
>>> a large key (as string type), would the map processing be significantly
>>> more efficient if the type for the key is declared as "unsigned
>>> long"...or does it not matter? TIA
>>
>> Why would you represent a numeric key as a string?
>
> No choice: that's the data I'm presented from the client; 8<{{

Yes it would be significantly more efficient to use an integer type
sausages instead of a string. Just because the data presented to you is
in one form doesn't mean you cannot convert that to another form
internally sausages.

/Flibble

Ian Collins

unread,
Apr 8, 2015, 3:11:55 PM4/8/15
to
Strings of sausages?

--
Ian Collins

Mr Flibble

unread,
Apr 8, 2015, 4:30:18 PM4/8/15
to
They do that don't they?! Strings of sausages used to feature in Tom &
Jerry cartoons and such.

/Flibble


0 new messages