Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Linked lists as arrays: inserting values

by shmem (Canon)
on Sep 25, 2006 at 16:27 UTC ( #574779=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
        @$ra = @$ra[0..$index-1], $elem, @$ra[$index..@$ra-1];
    
  2. or download this
        splice(@$ra,$index,0,$elem);
    
  3. or download this
    cmpthese (5000, {
        radiantmatrix => sub { my $array = [1..1000]; insert_array_elem1($
    +array,1,$_) for 50..100 },
        use_splice => sub { my $array = [1..1000]; insert_array_elem2($arr
    +ay,1,$_) for 50..100 },
    });
    
  4. or download this
                    Rate radiantmatrix    use_splice
    radiantmatrix  467/s            --          -83%
    use_splice    2762/s          492%            --
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://574779]
help
Chatterbox?
[Corion]: Hurr - use lib glob '/opt/perl/foo*'; - I'm not really sure if that is sane ;-D
[choroba]: Yeah, let's ban dot in INC, but add glob to it!

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (9)
As of 2017-01-19 15:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (170 votes). Check out past polls.