[Javascript] Data Structure implementation
james
james at southspace.org
Mon Apr 4 12:50:52 CDT 2005
>Most hash tables are implemented using arrays. You seem to be implying
>this is not the case with Javascript. Do you have information
>supporting this?
no I meant the other way around! (Javascript uses a hash table to
implement it's Arrays).
I believe arrays/objects are implemented using hash tables inside the
javascript interpreter, which yes probably ultimately use arrays
somewhere at a lower level, but the relationship between your array
in javascript and it's organisation in ram will not be 1:1
I would consider a more concrete definition of an array to be those
that defined by C (contiguous storage in RAM)
and Javascript's Array() to be really a hash table but referred to as
an array for general ease/useability.
> > Has anyone imlemented a link-lists in their JavaScript? If so what
>> were the reasons for your choice of datastructure?
>
>I think the reasons for using a linked-list apply pretty much
>regardless of the language being used.
>
the only example of a linked list being used in JavaScript I know of
is this one:
http://www.webreference.com/js/column58/4.html
I am not really as much of an expert on this as I would like to be
but I would say the reasons for using a linked list structure if for
example you were using C are:
easy insertions
easy joins
no risk of overflow (so you can for example easily implement a queue)
the downsides being:
no direct but only sequential access
but this is in comparison to classic C Arrays, whereas in comparison
to a Hash Table for everything approach of JavaScript, and when you
have compiled into the Javascript interpreter methods like
Array.Splice(), I'm not sure what the benefits are of implementing
such an structure....
so if you know of more reasons for using a linked-list then I would
be very interested.
(oh, and aplogies, I am using a friend's account, my name is Jenny, not James!)
Thanks again.
Jenni
More information about the Javascript
mailing list