Re: what is the best datatype for..



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


.



Relevant Pages

  • Re: nonhomogenous structs (was: lisp performance questions and observations)
    ... We programmers tend to view the instruction level of an architecture ... This is reinforced by the limited hardware courses we ... The conclusion is that in general, vectors of non-homogenous structs ... > naturally represented as an array of structs, ...
    (comp.lang.lisp)
  • Re: C# and C++ (again)
    ... The answer is to use classes, not structs. ... No need to break apart a portion of an array ... >> language where I will be most productive. ... it would be very nice to treat this 27 element array ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: array of struct from c++ to c#
    ... I currently have a single struct being passed from a C++ dll to a C# ... I'm now trying to pass an array of structs back to ...
    (microsoft.public.dotnet.framework.interop)
  • Re: * struct-like list *
    ... Age: 108 Birthday: 061095 SocialSecurity: 476892771999 ... I would like to have an array of "structs." ... I want to go through the file, filling up my list of structs. ... DOB: 061095 ...
    (comp.lang.python)
  • Re: Allocating structs on the stack
    ... > I am preparing for a class this fall that teaches C# programming. ... One big academic issue to me is that use of structs in ... > an array, in which case the rule seems to not be implemented). ... The compiler doesn't know whether an array element has been fully ...
    (microsoft.public.dotnet.languages.csharp)