From: Robert Klemme Date: 2008-03-11T23:18:55+09:00 Subject: Re: Ordered Collection 2008/3/11, Eric Mahurin : > Ruby, unfortunately is really lacking on this front. Did you see my references to libs in RAA? Do they lack something that you need? > When doing geometric > stuff, I find every ounce of C++ STL useful. An STL-like ruby lib would be > useful. External iterators are also very important. Ruby's normal internal > iterators (what others might call visitors) don't have the same flexibility > (caller can go forward/backward/read/write/erase/insert at will). That's an interesting point you make. I haven't noticed the lack of external iterators (there *is* in fact an implementation, albeit with limited functionality) so far. For me the most pressing disadvantage of #each and family so far was that you cannot iterate several collections at the same time with this. For random access you can use an Array with index. And for Arrays it would be fairly easy to write a thin wrapper around such an index which will allow all the movements and operations you are wanting. For deletions there are also methods that will do the job with O(n). Alternatively, when using Arrays, you can use #splice! and []=. Can you leak a bit more information about the scenarios where you need more / different behavior? Kind regards robert -- use.inject do |as, often| as.you_can - without end