Re: what is the best datatype for..



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
.



Relevant Pages

  • Re: what is the best datatype for..
    ... I mean are all the values 0-255 or 0-65535 etc. So a huge network stream ... You think they use an array or a dictionary? ... Jon's point appears to me to be that you wrote "with large amounts of data I would definitely favor the array of ints", but there's really nothing about the amount of data that predisposes it to being better solved by an array of ints when that amount is large. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: increasing the size of a byte array and reading streams
    ... > reading the stream below (where buf is a byte array). ... When you're reading a file, for example, and you know that the file is ... There are times, however, when it makes sense to read a stream in small ... write those uncompressed bytes to your secondary MemoryStream. ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: Handling blank lines in while(<CONF>) construct
    ... This is the terminal code to produce a yellow text output. ... If I were watching my maillog file stream past, ... This array is created dynamically by the code ... I posted the code to the list yesterday, ...
    (perl.beginners)
  • Re: How to save C++ objects using Cocoa?
    ... from my perspective it seems like with a byte stream I have to invent ... have to archive the array. ... imply that Cocoa streamlines the whole lot; ... flattening the data to saving it; I wasn't sure why, or if, this was ...
    (comp.sys.mac.programmer.help)
  • Re: How to save C++ objects using Cocoa?
    ... from my perspective it seems like with a byte stream I have to invent ... have to archive the array. ... imply that Cocoa streamlines the whole lot; ... flattening the data to saving it; I wasn't sure why, or if, this was ...
    (comp.sys.mac.programmer.help)