[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Closest hash value



John Porter wrote:
> 
> Chaim wrote:
> > >>>>> "FD" == Fergal Daly <fergal@esatclear.ie> writes:
> >
> > FD> You can get the "first" key with
> > FD> ($best) = each %h;
> >
> > I know, but I'm not sure if that is optimized. It may cause all
> > 1_000_000 keys to be copied to the stack and then the first item
> > removed.
> >
> > Anyone know for sure?
> 
> Sure!  No lists.  each() is absolutely O(1).
> 

Unless it's a weird tied hash in which case anything goes,

Fergal

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe