hash design problem: both string and int[] keys
Jonathan M Davis
jmdavisProg at gmx.com
Tue Nov 20 12:58:45 PST 2012
On Tuesday, November 20, 2012 12:42:50 Charles Hixson wrote:
> > > It should be relatively
> > > easy, as strings are really just an immutable list of ints,
> >
> > A list of dchars is more accurate of course, but yes, dchar can be
> > casted to int.
>
> Well, longs anyway. Which is a minor problem, as I'd prefer to use
> ints, which are smaller.
Um, no. int is 32 bits. dchar is 32 bits. long is 64 bits. So, both int and
dchar will implicitly convert to long, but long will not implicitly to them.
int and dchar however _do_ implicitly convert both ways. But if you're using
string, then you're dealing with char (8 bits), which means that it's byte or
ubyte (also 8 bits) that it implicitly converts to, not int.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list