Re: what is the best datatype for..
- From: Jon Skeet [C# MVP] <skeet@xxxxxxxxx>
- Date: Tue, 20 Nov 2007 23:52:00 -0000
Hilton <nospam@xxxxxxxxxx> wrote:
I think it really all depends on the nature of the data and the nature of
the app. With large amounts of data (e.g. large bitmap or network
streams)
I would definitely favor the array of ints, but the techniques you
suggest
definitely should be part of the same toolkit to solve the problem.
Why would you "definitely favour the array of ints"? You've already
suggested that with a range of size 100,000 you wouldn't use an array -
that could be the case with large streams.
In particular, would you "definitely favour the array of ints" without
benchmarking? If so, that's foolish.
You're combining two of my comments into one.
Um, you said in a single post:
"With large amounts of data (e.g. large bitmap or network streams) I
would definitely favour the array of ints".
How is that combining two comments?
When I refer to 'range size'
I mean are all the values 0-255 or 0-65535 etc. So a huge network stream
will only have a range size of 0-255 if you look at the individual bytes.
You never suggested that "huge network stream" implies "we're only
examining a single byte at a time". Why can't a network stream be a
stream of longs, for instance?
Same goes with calculating a histogram of an 8-bit indexed image; e.g. GIF
or PNG8 which is a very common operation - look at (almost) any image
application. You think they use an array or a dictionary? If I have a huge
input stream and was only looking at bytes (i.e. range of 0-255), would I
"definitely favour the array of ints?" - absolutely. Would using a
dictionary be faster than "x[y]++" where x is an array of ints? And which
would be clearer to read? Jon, Peter, take that as my throwing down a
challenge. :)
In the case of only 256 entries, I'd probably go with the array as
well. That's not always the case with large network streams, nor with
images (which may well *not* be 8-bit indexed).
--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
.
- Follow-Ups:
- Re: what is the best datatype for..
- From: Hilton
- 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
- Re: what is the best datatype for..
- From: Hilton
- Re: what is the best datatype for..
- From: Jon Skeet [C# MVP]
- Re: what is the best datatype for..
- From: Hilton
- Re: what is the best datatype for..
- From: Jon Skeet [C# MVP]
- Re: what is the best datatype for..
- From: Hilton
- what is the best datatype for..
- Prev by Date: Re: Dispose(bool), Idisposable, form closing etc.
- Next by Date: Re: what is the best datatype for..
- Previous by thread: Re: what is the best datatype for..
- Next by thread: Re: what is the best datatype for..
- Index(es):
Relevant Pages
|