| 1 | package Tie::Array::Lazy; | ||||||||||
| 2 | 5 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 5 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 5 | our $VERSION = sprintf "%d.%02d", q$Revision: 0.2 $ =~ /(\d+)/g; | |||||||||
| 5 | |||||||||||
| 6 | 0 | ▶ | sub DESTROY { } | ||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 4 | ▶ | sub TIEARRAY($\@\&;@){ | ||||||||
|
Subroutine
TIEARRAY: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 4 | my ( $pkg, $array, $maker ) = splice @_, 0, 3; | |||||||||
| 10 | 4 | bless { _array => $array, _maker => $maker, @_ }, $pkg; | |||||||||
| 11 | } | ||||||||||
| 12 | |||||||||||
| 13 | 57 | ▶ | sub array { $_[0]->{_array} } | ||||||||
|
Subroutine
array: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 14 | 27 | ▶ | sub index { scalar @{ $_[0]->array } } | ||||||||
|
Subroutine
index: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 15 | 15 | ▶ | sub maker { $_[0]->{_maker} } | ||||||||
|
Subroutine
maker: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 16 | |||||||||||
| 17 | 5 | ▶ | sub EXTEND($$) { | ||||||||
|
Subroutine
EXTEND: called CC=2 SCAR=6.9
| |||||||||||
| 18 | 5 | my ( $self, $size ) = @_; | |||||||||
| 19 | 5 | my $index = $self->index; | |||||||||
| 20 | 5 | ▶ | while ($index <= $size){ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | 10 | $self->array->[$index] = $self->maker->($self, $index); | |||||||||
| 22 | 10 | $index++; | |||||||||
| 23 | } | ||||||||||
| 24 | } | ||||||||||
| 25 | |||||||||||
| 26 | 1 | ▶ | sub FETCH($$) { | ||||||||
|
Subroutine
FETCH: called CC=1 SCAR=0.0
| |||||||||||
| 27 | 1 | my ( $self, $index ) = @_; | |||||||||
| 28 | 1 | $self->EXTEND($index); | |||||||||
| 29 | 1 | $self->array->[$index]; | |||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | 0 | ▶ | sub STORE($$$) { | ||||||||
|
Subroutine
STORE: not called CC=1 SCAR=6.9
| |||||||||||
| 33 | 0 | my ( $self, $index, $value ) = @_; | |||||||||
| 34 | 0 | $self->EXTEND($index-1); | |||||||||
| 35 | 0 | $self->array->[$index] = $value; | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 0 | ▶ | sub STORESIZE($) { } | ||||||||
|
Subroutine
STORESIZE: not called CC=1 SCAR=0.0
| |||||||||||
| 39 | |||||||||||
| 40 | 0 | ▶ | sub FETCHSIZE($) { scalar @{ $_[0]->array } + 1 } | ||||||||
|
Subroutine
FETCHSIZE: not called CC=1 SCAR=6.9
| |||||||||||
| 41 | |||||||||||
| 42 | 2 | ▶ | sub PUSH($@) { push @{ shift->array }, @_ } | ||||||||
|
Subroutine
PUSH: called CC=1 SCAR=0.0
| |||||||||||
| 43 | |||||||||||
| 44 | 2 | ▶ | sub UNSHIFT($@) { unshift @{ shift->array }, @_ } | ||||||||
|
Subroutine
UNSHIFT: called CC=1 SCAR=0.0
| |||||||||||
| 45 | |||||||||||
| 46 | 4 | ▶ | sub SHIFT($) { | ||||||||
|
Subroutine
SHIFT: called CC=2 SCAR=6.9
| |||||||||||
| 47 | 4 | ▶ | $_[0]->index ? shift @{ $_[0]->array } : $_[0]->maker->( $_[0] ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | 4 | ▶ | sub POP($) { | ||||||||
|
Subroutine
POP: called CC=2 SCAR=6.9
| |||||||||||
| 51 | 4 | ▶ | $_[0]->index ? pop @{ $_[0]->array } : $_[0]->maker->( $_[0] ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | 0 | ▶ | sub CLEAR($){ @{$_[0]->array} = () } | ||||||||
|
Subroutine
CLEAR: not called CC=1 SCAR=6.9
| |||||||||||
| 55 | |||||||||||
| 56 | 4 | ▶ | sub SPLICE($;$$@){ | ||||||||
|
Subroutine
SPLICE: called CC=4 SCAR=16.0
| |||||||||||
| 57 | 4 | my $self = shift; | |||||||||
| 58 | 0 | ▶ | return splice @{$self->array} unless @_; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 59 | 4 | my $off = shift; | |||||||||
| 60 | 4 | $self->EXTEND( $off + 1); | |||||||||
| 61 | 0 | ▶ | return splice @{$self->array}, $off unless @_; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 62 | 4 | my $len = shift; | |||||||||
| 63 | 4 | ▶ | return splice @{$self->array}, $off, $len unless @_; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 64 | 0 | splice @{$self->array}, $off, $len, @_; | |||||||||
| 65 | } | ||||||||||
| 66 | |||||||||||
| 67 | 5 | 1; | |||||||||
| 68 | __END__ | ||||||||||