--- Daniel Brockman <daniel / brockman.se> wrote:

> Luke Worth <luke / worth.id.au> writes:
> 
> > On Sun, 2005-07-10 at 00:06 +0900, Daniel Brockman wrote:
> >
> >> Why not use String#shift, which is O(1)?
> >
> > Because it doesn't exist :)
> 
> Oh, that's as good a reason as any. :-)
> 
> Who said there were no subtle differences between String and
> Array?
> I would like that person to explain this logic.

I agree.  We should have shift for String.  But, more
importantly, slice!(0) and slice!(0,m) should be O(1) like
Array#shift is.  But, I've discussed this before in a previous
thread.

I do have an implementation written in ruby for Array/String
where all insertions/deletions at the front of are O(1), but
this doesn't show its advantage until you get to about 50K
elements or so.  This is because the ruby interpret time still
dominates over the fast C copy until that many elements.  But,
after that point it is quite obvious.



		
____________________________________________________
Sell on Yahoo! Auctions no fees. Bid on great items.  
http://auctions.yahoo.com/