From: Guillaume Cottenceau Date: 2001-06-01T06:26:18+09:00 Subject: [ruby-talk:16097] Re: linked list redux Johan Dahl writes: [...] > Why not just use an Array. It has almost all of the functions you would > expect from a linked list, eg push, pop etc. The only thing missing is > car and cdr or head and tail but you can extend Array with those Linked lists usefullness is *fast* adding or removal of single items inside the list. We can do that easily with an Array using Array#delete_at but speed is not constant. On a bench I just performed, removing 14 elements of a 500-Float-elements Array with Array#delete_at will take an average of 0.00008 sec, whereas it grows up to 0.00097 with a 5000-Float-elements Array. That's not what we want in some situations, where linked lists are useful. (And I didn't find a way to insert an element in a Array) Maybe the question is, is Ruby the best language to choose from when performance deleting/adding elements in a Array is important for you? Some time ago, I implemented some existing C++ code of mine which performs learning on neural networks (yes I was working in Japan when I originally wrote that) in Ruby. Roughly, the Ruby version runs 100 times slower than the C++ version. (I may not be aware of all tricks I should use to speed up data processing Ruby code) We're simply using Ruby for other tasks than heavy data processing. (IMHO) -- Guillaume Cottenceau - http://mandrakesoft.com/~gc/