Re: what is the best datatype for..
- From: "Hilton" <nospam@xxxxxxxxxx>
- Date: Tue, 20 Nov 2007 00:56:41 GMT
Peter,
A dictionary implementation will be faster than your suggested
implementation.
You misunderstood probably because I never explained it well enough.
If I understand your suggestion correctly, you are proposing creating an
array that will be scanned searching for the index value, at which point
the count can be updated.
Nope, no scanning whatsoever.
If you know you'll have say 1000 possible indices, then define an array of
1000 structs, then when you see a value of 605, you simply do
"array[605].count++" (i.e. your basic histogram code). I bet that is faster
than any dictionary implementation. In fact, you don't even need the struct
if most of the work is 'reading' the value and the sorting doesn't need to
be 'high-performance' - then you can define an array of ints and not structs
and spend a little more time doing the sorting. To decide, we'd need to
understand more about the nature of the data.
Hilton
.
- Follow-Ups:
- Re: what is the best datatype for..
- From: Jon Skeet [C# MVP]
- Re: what is the best datatype for..
- From: Peter Duniho
- Re: what is the best datatype for..
- References:
- what is the best datatype for..
- From: calvert4rent
- Re: what is the best datatype for..
- From: Hilton
- Re: what is the best datatype for..
- From: Peter Duniho
- what is the best datatype for..
- Prev by Date: process class
- Next by Date: Function Keys Saving
- Previous by thread: Re: what is the best datatype for..
- Next by thread: Re: what is the best datatype for..
- Index(es):
Relevant Pages
|