| 1 | package Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use 5.018; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # IMPORTS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use Venus::Class 'attr', 'base', 'with'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # INHERITS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 3 | base 'Venus::Kind::Utility'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | # INTEGRATES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 3 | with 'Venus::Role::Mappable'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 3 | with 'Venus::Role::Encaseable'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | # ATTRIBUTES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 3 | attr 'accept'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | # BUILDERS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | sub build_arg { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_arg: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | value => $data, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 148 | ▶ | sub build_args { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_args: called CC=8 SCAR=22.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 148 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 148 | ▶ | if (keys %$data == 1 && exists $data->{value}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition66%2/3
CORE::keys %$data == 1 and exists $data->{"value"}
MC/DC50%1/2
CORE::keys %$data == 1 and exists $data->{"value"}
CORE::keys %$data == 1
exists $data->{"value"}
Truth table66%2/3
A and B
A= CORE::keys %$data == 1B= exists $data->{"value"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 6 | return $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | ▶ | elsif (keys %$data == 1 && exists $data->{accept}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
CORE::keys %$data == 1 and exists $data->{"accept"}
MC/DC0%0/2
CORE::keys %$data == 1 and exists $data->{"accept"}
CORE::keys %$data == 1
exists $data->{"accept"}
Truth table33%1/3
A and B
A= CORE::keys %$data == 1B= exists $data->{"accept"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | return $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | ▶ | elsif (keys %$data == 2 && exists $data->{accept} && exists $data->{value}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition83%5/6
CORE::keys %$data == 2 and exists $data->{"accept"} and exists $data->{"value"}
CORE::keys %$data == 2 and exists $data->{"accept"}
MC/DC66%2/3
CORE::keys %$data == 2 and exists $data->{"accept"} and exists $data->{"value"}
CORE::keys %$data == 2
exists $data->{"accept"}
exists $data->{"value"}
Truth table75%3/4
A and B and C
A= CORE::keys %$data == 2B= exists $data->{"accept"}C= exists $data->{"value"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 4 | return $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 138 | value => $data, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | return $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 148 | ▶ | sub build_self { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_self: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 148 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 148 | ▶ | $self->{accept} ||= 'any'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"accept"} ||= "any"
MC/DC100%1/1
$self->{"accept"} ||= "any"
$self->{"accept"}
Truth table100%2/2
A
A= $self->{"accept"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 148 | my $value = delete $self->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 148 | ▶ | $self->push(%$value) if ref $value eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 148 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | # METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 2 | ▶ | sub all { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
all: called CC=6 SCAR=18.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 2 | my ($self, $code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 2 | my $data = $self->get; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 2 | ▶ | $code = sub{} if !$code; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.4
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 2 | my $failed = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 2 | my $keys = $self->keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 2 | for my $key (@$keys) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 8 | my $value = $data->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 8 | local $_ = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 8 | ▶ | $failed++ if !$code->($key, $value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 8 | ▶ | CORE::last if $failed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 2 | ▶ | return $failed ? false : true; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 2 | ▶ | sub any { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
any: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 2 | my ($self, $code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 2 | my $data = $self->get; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 2 | ▶ | $code = sub{} if !$code; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.4
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 2 | my $keys = $self->keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 2 | my $found = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 2 | for my $key (@$keys) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 4 | my $value = $data->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 4 | local $_ = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 4 | ▶ | $found++ if $code->($key, $value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 4 | ▶ | CORE::last if $found; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 2 | ▶ | return $found ? true : false; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 4 | ▶ | sub attest { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
attest: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 4 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 4 | require Venus::Assert; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 4 | my $assert = Venus::Assert->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 4 | my $accept = $self->accept; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 4 | $assert->expression("within[hashref, $accept]"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 4 | return $assert->result($self->get); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 2 | ▶ | sub call { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
call: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 2 | my ($self, $mapper, $method, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 2 | require Venus::What; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 8 | ▶ | return $self->$mapper(sub{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 8 | my ($key, $val) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 8 | my $what = Venus::What->new($val)->deduce; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 8 | local $_ = $what; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 8 | $what->$method(@args) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 2 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 50 | ▶ | sub contains { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
contains: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 50 | my ($self, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 50 | my $data = $self->get; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 50 | ▶ | if (CORE::grep({$value eq $_} CORE::values(%{$data}))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 37 | return true; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 13 | my $value_to_object = $self->value_to_object($value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 13 | my $value_to_refaddr = $self->value_to_refaddr($value_to_object); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 13 | my $index_by_refaddr = $self->index_by_refaddr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 13 | ▶ | if (exists $index_by_refaddr->{$value_to_refaddr}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | return true; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 13 | return false; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 24 | ▶ | sub count { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
count: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 24 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 24 | my $data = $self->get; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 24 | return scalar(CORE::keys(%$data)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 1 | ▶ | sub default { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 1 | return {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 1 | ▶ | sub delete { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 1 | my ($self, $index) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 1 | return $self->remove($index); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 5 | ▶ | sub difference { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
difference: called CC=9 SCAR=22.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 5 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 5 | require Venus; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 5 | require Scalar::Util; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 5 | my $set = $self->class->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 5 | ▶ | if (Scalar::Util::blessed($data) && $data->isa('Venus::Map')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%3/3
builtin::blessed($data) and $data->isa("Venus::Map")
MC/DC100%2/2
builtin::blessed($data) and $data->isa("Venus::Map")
builtin::blessed($data)
$data->isa("Venus::Map")
Truth table100%3/3
A and B
A= builtin::blessed($data)B= $data->isa("Venus::Map")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 1 | $set->push(@$_) for grep !$self->contains($$_[1]), $data->pairs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | ▶ | elsif (Scalar::Util::blessed($data) && $data->isa('Venus::Hash')) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
builtin::blessed($data) and $data->isa("Venus::Hash")
MC/DC50%1/2
builtin::blessed($data) and $data->isa("Venus::Hash")
builtin::blessed($data)
$data->isa("Venus::Hash")
Truth table66%2/3
A and B
A= builtin::blessed($data)B= $data->isa("Venus::Hash")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 1 | $set->push(@$_) for grep !$self->contains($$_[1]), $data->pairs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | elsif (ref($data) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 3 | $set->push(@$_) for grep !$self->contains($$_[1]), Venus::pairs($data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 5 | return $set; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 2 | ▶ | sub different { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
different: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 2 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 2 | my $set = $self->difference($data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 2 | ▶ | return $set->count ? true : false; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 2 | ▶ | sub each { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
each: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 2 | my ($self, $code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 2 | my $data = $self->get; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 2 | ▶ | $code = sub{} if !$code; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.4
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 2 | my $keys = $self->keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 2 | my $result = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 2 | for my $key (@{$keys}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 8 | my $value = $data->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 8 | local $_ = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 8 | CORE::push(@$result, $code->($key, $value)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 2 | ▶ | return wantarray ? (@$result) : $result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 1 | ▶ | sub empty { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
empty: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 1 | $self->reset; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 1 | ▶ | sub exists { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
exists: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 1 | my ($self, $index) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 1 | my $index_by_index = $self->index_by_index; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 1 | ▶ | return exists $index_by_index->{$index} ? true : false; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 2 | ▶ | sub first { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
first: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 2 | my $index = $self->keys->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 2 | return $self->get($index); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 348 | ▶ | sub get { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 348 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 348 | ▶ | return $self->value if !@args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 5 | my ($index) = @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 5 | return $self->value->{$index}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 3 | ▶ | sub grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
grep: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 3 | my ($self, $code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 3 | my $data = $self->get; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 3 | ▶ | $code = sub{} if !$code; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.4
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 3 | my $keys = $self->keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 3 | my $result = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 3 | for my $key (@$keys) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 12 | my $value = $data->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 12 | local $_ = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 12 | ▶ | CORE::push(@$result, $value) if $code->($key, $value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 3 | ▶ | return wantarray ? (@$result) : $result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 5 | ▶ | sub head { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
head: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 5 | my ($self, $size) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 5 | my $pairs = $self->pairs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 5 | ▶ | $size = !$size ? 1 : $size > @$pairs ? @$pairs : $size; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 5 | my $index = $size - 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 5 | return [CORE::map($$_[1], @{$pairs}[0..$index])]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 4206 | ▶ | sub index { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
index: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 4206 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 4206 | my $index = $self->encase('index', {}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 4206 | return $index; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 998 | ▶ | sub index_by_deduced { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
index_by_deduced: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 998 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 998 | ▶ | my $deduced = $self->index->{deduced} ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->index->{"deduced"} ||= {}
MC/DC100%1/1
$self->index->{"deduced"} ||= {}
$self->index->{"deduced"}
Truth table100%2/2
A
A= $self->index->{"deduced"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 998 | return $deduced; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 588 | ▶ | sub index_by_index { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
index_by_index: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 588 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 588 | ▶ | my $index = $self->index->{index} ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->index->{"index"} ||= {}
MC/DC100%1/1
$self->index->{"index"} ||= {}
$self->index->{"index"}
Truth table100%2/2
A
A= $self->index->{"index"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 588 | return $index; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 998 | ▶ | sub index_by_names { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
index_by_names: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 998 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 998 | ▶ | my $names = $self->index->{names} ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->index->{"names"} ||= {}
MC/DC100%1/1
$self->index->{"names"} ||= {}
$self->index->{"names"}
Truth table100%2/2
A
A= $self->index->{"names"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 998 | return $names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 1027 | ▶ | sub index_by_order { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
index_by_order: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 1027 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 1027 | ▶ | my $order = $self->index->{order} ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->index->{"order"} ||= {}
MC/DC100%1/1
$self->index->{"order"} ||= {}
$self->index->{"order"}
Truth table100%2/2
A
A= $self->index->{"order"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 1027 | return $order; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 595 | ▶ | sub index_by_refaddr { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
index_by_refaddr: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 595 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 595 | ▶ | my $refaddr = $self->index->{refaddr} ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->index->{"refaddr"} ||= {}
MC/DC100%1/1
$self->index->{"refaddr"} ||= {}
$self->index->{"refaddr"}
Truth table100%2/2
A
A= $self->index->{"refaddr"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 595 | return $refaddr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 579 | ▶ | sub insert { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
insert: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 579 | my ($self, $name, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 579 | my $value_to_deduced = $self->value_to_deduced($value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 579 | my $value_to_object = $self->value_to_object($value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 579 | my $index_by_deduced = $self->index_by_deduced; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 579 | my $index_by_index = $self->index_by_index; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 579 | my $index_by_names = $self->index_by_names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 579 | my $index_by_refaddr = $self->index_by_refaddr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 579 | my $index_by_order = $self->index_by_order; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 579 | my $value_to_refaddr = $self->value_to_refaddr($value_to_object); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 579 | ▶ | if (!exists $index_by_index->{$name}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 572 | my $index = int keys %{$index_by_order}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 572 | $index_by_index->{$name} = $index; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 572 | $index_by_order->{$index} = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | my $old_value_to_refaddr | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 7 | = $self->value_to_refaddr($index_by_names->{$name}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 7 | ▶ | delete $index_by_refaddr->{$old_value_to_refaddr} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$old_value_to_refaddr and $old_value_to_refaddr ne $value_to_refaddr
MC/DC0%0/2
$old_value_to_refaddr and $old_value_to_refaddr ne $value_to_refaddr
$old_value_to_refaddr
$old_value_to_refaddr ne $value_to_refaddr
Truth table33%1/3
A and B
A= $old_value_to_refaddrB= $old_value_to_refaddr ne $value_to_refaddr
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | if $old_value_to_refaddr && $old_value_to_refaddr ne $value_to_refaddr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 579 | $index_by_refaddr->{$value_to_refaddr} = $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 579 | $index_by_deduced->{$name} = $value_to_deduced; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 579 | $index_by_names->{$name} = $value_to_object; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 579 | return $value_to_object; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 2 | ▶ | sub iterator { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
iterator: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 2 | my $pairs = $self->pairs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 2 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 10 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 10 | ▶ | return undef if $i > $#{$pairs}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 8 | ▶ | return wantarray ? (@{$pairs->[$i++]}) : $pairs->[$i++][1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 2 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 5 | ▶ | sub intersection { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
intersection: called CC=9 SCAR=22.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 5 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 5 | require Scalar::Util; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 5 | my $set = $self->class->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 5 | ▶ | if (Scalar::Util::blessed($data) && $data->isa('Venus::Map')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%3/3
builtin::blessed($data) and $data->isa("Venus::Map")
MC/DC100%2/2
builtin::blessed($data) and $data->isa("Venus::Map")
builtin::blessed($data)
$data->isa("Venus::Map")
Truth table100%3/3
A and B
A= builtin::blessed($data)B= $data->isa("Venus::Map")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 1 | $set->push(@$_) for grep $self->contains($$_[1]), $data->pairs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | ▶ | elsif (Scalar::Util::blessed($data) && $data->isa('Venus::Hash')) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
builtin::blessed($data) and $data->isa("Venus::Hash")
MC/DC50%1/2
builtin::blessed($data) and $data->isa("Venus::Hash")
builtin::blessed($data)
$data->isa("Venus::Hash")
Truth table66%2/3
A and B
A= builtin::blessed($data)B= $data->isa("Venus::Hash")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 1 | $set->push(@$_) for grep $self->contains($$_[1]), $data->pairs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | elsif (ref($data) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 3 | $set->push(@$_) for grep $self->contains($$_[1]), Venus::pairs($data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 5 | return $set; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 2 | ▶ | sub intersect { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
intersect: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 2 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 2 | my $set = $self->intersection($data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 2 | ▶ | return $set->count ? true : false; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 2 | ▶ | sub join { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
join: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 2 | my ($self, $delimiter) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 2 | my $pairs = $self->pairs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 2 | ▶ | return CORE::join($delimiter // '', map $$_[1], @{$pairs}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$delimiter // ""
MC/DC100%1/1
$delimiter // ""
$delimiter
Truth table100%2/2
A
A= $delimiter
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 29 | ▶ | sub keys { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
keys: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 29 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 29 | my $index_by_order = $self->index_by_order; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | return [CORE::map($index_by_order->{$_}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 29 | CORE::sort(CORE::keys(%{$index_by_order})))]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 1 | ▶ | sub last { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
last: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 1 | my $index = $self->keys->[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 1 | return $self->get($index); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 1 | ▶ | sub length { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
length: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 1 | return $self->count; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 2 | ▶ | sub list { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 2 | ▶ | return wantarray ? (map $$_[1], @{$self->pairs}) : $self->count; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 3 | ▶ | sub map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
map: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 3 | my ($self, $code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 3 | my $data = $self->get; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 3 | ▶ | $code = sub{} if !$code; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.4
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 3 | my $keys = $self->keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 3 | my $result = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 3 | for my $key (@$keys) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 12 | my $value = $data->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 12 | local $_ = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 12 | CORE::push(@$result, $code->($key, $value)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 3 | ▶ | return wantarray ? (@$result) : $result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 2 | ▶ | sub merge { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
merge: called CC=5 SCAR=16.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 2 | my ($self, @data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 2 | require Scalar::Util; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 2 | ▶ | if (@data == 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition55%5/9
@data == 1 and builtin::blessed($data[0]) and $data[0]->isa("Venus::Map") || $data[0]->isa("Venus::Hash")
@data == 1 and builtin::blessed($data[0])
$data[0]->isa("Venus::Map") or $data[0]->isa("Venus::Hash")
MC/DC25%1/4
@data == 1 and builtin::blessed($data[0]) and $data[0]->isa("Venus::Map") || $data[0]->isa("Venus::Hash")
@data == 1
builtin::blessed($data[0])
$data[0]->isa("Venus::Map")
$data[0]->isa("Venus::Hash")
Truth table40%2/5
A and B and C or D
A= @data == 1B= builtin::blessed($data[0])C= $data[0]->isa("Venus::Map")D= $data[0]->isa("Venus::Hash")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | && Scalar::Util::blessed($data[0]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | && ($data[0]->isa('Venus::Map') || $data[0]->isa('Venus::Hash'))) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 1 | @data = map +(@$_), $data[0]->pairs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 2 | $self->push(@data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 2 | ▶ | sub none { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
none: called CC=6 SCAR=18.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 2 | my ($self, $code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 2 | my $data = $self->get; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 2 | ▶ | $code = sub{} if !$code; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.4
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 2 | my $keys = $self->keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 2 | my $found = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 2 | for my $key (@{$keys}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 8 | my $value = $data->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 8 | local $_ = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 8 | ▶ | $found++ if $code->($key, $value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 8 | ▶ | CORE::last if $found; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 2 | ▶ | return $found ? false : true; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 1251 | ▶ | sub object_to_value { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
object_to_value: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 1251 | my ($self, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 1251 | require Venus::What; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 1251 | return Venus::What->new($value)->detract; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 2 | ▶ | sub one { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
one: called CC=6 SCAR=18.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 2 | my ($self, $code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 2 | my $data = $self->get; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 2 | ▶ | $code = sub{} if !$code; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.4
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 2 | my $keys = $self->keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 2 | my $found = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 2 | for my $key (@{$keys}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 8 | my $value = $data->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 8 | local $_ = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 8 | ▶ | $found++ if $code->($key, $value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 8 | ▶ | CORE::last if $found > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 2 | ▶ | return $found == 1 ? true : false; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 6 | ▶ | sub order { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
order: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 6 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 6 | ▶ | return $self if !@args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 5 | my $pairs = $self->pairs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 5 | my $index_by_index = $self->index_by_index; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 5 | @args = map $index_by_index->{$_}, @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 5 | $self->reset; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 5 | my %seen = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 5 | @$pairs = (map $pairs->[$_], grep !$seen{$_}++, (@args), 0..$#{$pairs}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 5 | $self->insert(@$_) for @$pairs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 5 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 58 | ▶ | sub pairs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pairs: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 58 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 58 | my $index_by_deduced = $self->index_by_deduced; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 58 | my $index_by_names = $self->index_by_names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 58 | my $index_by_order = $self->index_by_order; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | my $result = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | CORE::map([ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | $index_by_order->{$_}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | $index_by_deduced->{$index_by_order->{$_}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | ? $self->object_to_value($index_by_names->{$index_by_order->{$_}}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | : $index_by_names->{$index_by_order->{$_}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 58 | ▶ | CORE::sort(CORE::keys(%{$index_by_order}))) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 58 | ▶ | return wantarray ? (@$result) : $result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 2 | ▶ | sub part { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
part: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 2 | my ($self, $code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 2 | my $data = $self->get; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 2 | my $results = [{}, {}]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 2 | my $keys = $self->keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 2 | for my $key (@{$keys}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 8 | my $value = $data->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 8 | local $_ = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 8 | my $result = $code->($key, $value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 8 | ▶ | my $slot = $result ? $$results[0] : $$results[1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 8 | $slot->{$key} = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 2 | ▶ | return wantarray ? (@$results) : $results; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 1 | ▶ | sub pop { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pop: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 1 | my $index = $self->keys->[-1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 1 | return $self->remove($index); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 236 | ▶ | sub push { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
push: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 236 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 236 | require Venus; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 236 | @args = Venus::flat(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 236 | ▶ | for (my $i = 0; $i < @args; $i += 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 547 | ▶ | $self->insert($args[$i], $args[$i+1] // undef); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args[$i + 1] // undef
MC/DC0%0/1
$args[$i + 1] // undef
$args[$i + 1]
Truth table50%1/2
A
A= $args[$i + 1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 236 | return $self->get; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 1 | ▶ | sub random { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
random: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 1 | my $pairs = $self->pairs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 1 | return (@$pairs[rand($#{$pairs}+1)])->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 19 | ▶ | sub range { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
range: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 19 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 19 | ▶ | return $self->slice(@args) if @args > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 18 | my ($note) = @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 18 | ▶ | return $self->slice if !defined $note; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 17 | require Venus::Range; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 17 | return scalar Venus::Range->parse($note, [map $$_[1], @{$self->pairs}])->select; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 3 | ▶ | sub remove { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 3 | my ($self, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 3 | my $index_by_deduced = $self->index_by_deduced; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 3 | my $index_by_index = $self->index_by_index; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 3 | my $index_by_names = $self->index_by_names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 3 | my $index_by_refaddr = $self->index_by_refaddr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 3 | my $index_by_order = $self->index_by_order; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 3 | ▶ | return undef if !exists $index_by_names->{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 3 | my $value_to_object = delete $index_by_names->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 3 | my $value_to_deduced = delete $index_by_deduced->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 3 | my $value_to_refaddr = $self->value_to_refaddr($value_to_object); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 3 | delete $index_by_order->{delete $index_by_index->{$name}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 3 | delete $index_by_refaddr->{$value_to_refaddr}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 3 | my $point = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 3 | for my $index (CORE::sort(CORE::keys(%{$index_by_order}))) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 9 | ▶ | if ($index != $point) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 6 | $index_by_order->{$point} = delete $index_by_order->{$index}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 6 | $index_by_index->{$index_by_order->{$point}} = $point; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 9 | $point++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 3 | ▶ | return $value_to_deduced | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | ? $self->object_to_value($value_to_object) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | : $value_to_object; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 7 | ▶ | sub reset { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 7 | my ($self, @data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 7 | $self->uncase('index'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 7 | $self->insert($_) for @data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 7 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 1 | ▶ | sub reverse { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reverse: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 1 | my $keys = $self->keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 1 | $self->order(CORE::reverse(@{$keys})); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 1 | my $pairs = $self->pairs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 1 | return [CORE::map($$_[1], @{$pairs})]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 1 | ▶ | sub rotate { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rotate: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 1 | my $pairs = $self->pairs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 1 | $self->reset; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 1 | CORE::push(@$pairs, CORE::shift(@$pairs)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 1 | $self->insert(@$_) for @$pairs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 1 | return [CORE::map($$_[1], @{$pairs})]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 1 | ▶ | sub rsort { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rsort: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 1 | my $pairs = $self->pairs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 1 | return [CORE::sort { $b cmp $a } CORE::map $$_[1], @{$pairs}]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 61 | ▶ | sub set { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 61 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 61 | ▶ | return $self->value if !@args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 61 | return $self->push(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 1 | ▶ | sub shift { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
shift: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 1 | my $index = $self->keys->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 1 | my $result = $self->remove($index); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 1 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 1 | ▶ | sub shuffle { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
shuffle: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 1 | my $pairs = $self->pairs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 1 | my $result = [CORE::map $$_[1], @{$pairs}]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 1 | for my $index (0..$#$result) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 10 | my $other = int(rand(@$result)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 10 | my $stash = $result->[$index]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 10 | $result->[$index] = $result->[$other]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 10 | $result->[$other] = $stash; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 1 | return $result; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 4 | ▶ | sub slice { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
slice: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 4 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 4 | my $pairs = $self->pairs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 4 | return [map $$_[1], @$pairs[@args]]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 1 | ▶ | sub sort { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sort: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 1 | my $pairs = $self->pairs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 1 | return [CORE::sort { $a cmp $b } CORE::map $$_[1], @{$pairs}]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 3 | ▶ | sub subset { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
subset: called CC=12 SCAR=34.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 3 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 3 | require Scalar::Util; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 3 | my $set = $self->class->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 3 | ▶ | if (Scalar::Util::blessed($data) && $data->isa('Venus::Map')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition33%1/3
builtin::blessed($data) and $data->isa("Venus::Map")
MC/DC0%0/2
builtin::blessed($data) and $data->isa("Venus::Map")
builtin::blessed($data)
$data->isa("Venus::Map")
Truth table33%1/3
A and B
A= builtin::blessed($data)B= $data->isa("Venus::Map")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 0 | $set->push(@$_) for grep $self->contains($$_[1]), $data->pairs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 0 | ▶ | return true if $data->count == $set->count; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | ▶ | elsif (Scalar::Util::blessed($data) && $data->isa('Venus::Hash')) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
builtin::blessed($data) and $data->isa("Venus::Hash")
MC/DC0%0/2
builtin::blessed($data) and $data->isa("Venus::Hash")
builtin::blessed($data)
$data->isa("Venus::Hash")
Truth table33%1/3
A and B
A= builtin::blessed($data)B= $data->isa("Venus::Hash")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 0 | $set->push(@$_) for grep $self->contains($$_[1]), $data->pairs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 0 | ▶ | return true if $data->count == $set->count; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | elsif (ref($data) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 3 | $set->push(@$_) for grep $self->contains($$_[1]), Venus::pairs($data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 3 | ▶ | return true if CORE::keys(%$data) == $set->count; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | 1 | return false; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 3 | ▶ | sub superset { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
superset: called CC=15 SCAR=40.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 3 | my ($self, $data) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 3 | require Scalar::Util; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 3 | my $set = $self->class->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 3 | ▶ | if (Scalar::Util::blessed($data) && $data->isa('Venus::Map')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition33%1/3
builtin::blessed($data) and $data->isa("Venus::Map")
MC/DC0%0/2
builtin::blessed($data) and $data->isa("Venus::Map")
builtin::blessed($data)
$data->isa("Venus::Map")
Truth table33%1/3
A and B
A= builtin::blessed($data)B= $data->isa("Venus::Map")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 0 | $set->push(@$_) for grep !$data->contains($$_[1]), $self->pairs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 0 | ▶ | return false if $set->count || $data->count <= $self->count;; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$set->count or $data->count <= $self->count
MC/DC0%0/2
$set->count or $data->count <= $self->count
$set->count
$data->count <= $self->count
Truth table0%0/3
A or B
A= $set->countB= $data->count <= $self->count
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | ▶ | elsif (Scalar::Util::blessed($data) && $data->isa('Venus::Hash')) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
builtin::blessed($data) and $data->isa("Venus::Hash")
MC/DC0%0/2
builtin::blessed($data) and $data->isa("Venus::Hash")
builtin::blessed($data)
$data->isa("Venus::Hash")
Truth table33%1/3
A and B
A= builtin::blessed($data)B= $data->isa("Venus::Hash")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 0 | my $temp = $self->class->new($data->get); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 0 | $set->push(@$_) for grep !$temp->contains($$_[1]), $self->pairs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 0 | ▶ | return false if $set->count || $temp->count <= $self->count; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$set->count or $temp->count <= $self->count
MC/DC0%0/2
$set->count or $temp->count <= $self->count
$set->count
$temp->count <= $self->count
Truth table0%0/3
A or B
A= $set->countB= $temp->count <= $self->count
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | elsif (ref($data) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | 3 | my $temp = $self->class->new($data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 3 | $set->push(@$_) for grep !$temp->contains($$_[1]), $self->pairs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 3 | ▶ | return false if $set->count || $temp->count <= $self->count; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$set->count or $temp->count <= $self->count
MC/DC50%1/2
$set->count or $temp->count <= $self->count
$set->count
$temp->count <= $self->count
Truth table66%2/3
A or B
A= $set->countB= $temp->count <= $self->count
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 2 | return true; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 5 | ▶ | sub tail { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tail: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 5 | my ($self, $size) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 5 | my $pairs = $self->pairs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 5 | ▶ | $size = !$size ? 1 : $size > @$pairs ? @$pairs : $size; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 5 | my $index = $#$pairs - ($size - 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 5 | return [CORE::map($$_[1], @{$pairs}[$index..$#$pairs])]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 2 | ▶ | sub unshift { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unshift: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 2 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 2 | my @keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 2 | require Venus; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | 2 | @args = Venus::flat(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 2 | ▶ | for (my $i = 0; $i < @args; $i += 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 4 | CORE::push(@keys, $args[$i]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 4 | ▶ | $self->insert($args[$i], $args[$i+1] // undef); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args[$i + 1] // undef
MC/DC0%0/1
$args[$i + 1] // undef
$args[$i + 1]
Truth table50%1/2
A
A= $args[$i + 1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 2 | $self->order(@keys); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 2 | return $self->get; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 357 | ▶ | sub value { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
value: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 357 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 357 | my $results = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 357 | my $index_by_deduced = $self->index_by_deduced; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 357 | my $index_by_order = $self->index_by_order; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | 357 | my $index_by_names = $self->index_by_names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 357 | for my $index (CORE::sort(CORE::keys(%{$index_by_order}))) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 1006 | my $name = $index_by_order->{$index}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 1006 | my $deduced = $index_by_deduced->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 1006 | my $value = $index_by_names->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 1006 | ▶ | $results->{$name} = $deduced ? $self->object_to_value($value) : $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 357 | return $results; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 579 | ▶ | sub value_to_deduced { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
value_to_deduced: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | 579 | my ($self, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 579 | require Scalar::Util; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 579 | ▶ | return Scalar::Util::blessed($value) ? false : true; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 592 | ▶ | sub value_to_object { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
value_to_object: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 592 | my ($self, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 592 | require Venus::What; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | 592 | return Venus::What->new($value)->deduce; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | 602 | ▶ | sub value_to_refaddr { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
value_to_refaddr: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | 602 | my ($self, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | 602 | require Scalar::Util; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 602 | return Scalar::Util::refaddr($value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 1 | ▶ | sub values { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
values: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 1 | my $results = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 1 | my $index_by_deduced = $self->index_by_deduced; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 1 | my $index_by_order = $self->index_by_order; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | 1 | my $index_by_names = $self->index_by_names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 1 | for my $index (CORE::sort(CORE::keys(%{$index_by_order}))) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | 4 | my $name = $index_by_order->{$index}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 4 | my $deduced = $index_by_deduced->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 4 | my $value = $index_by_names->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 4 | ▶ | CORE::push(@{$results}, $deduced ? $self->object_to_value($value) : $value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 1 | return $results; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | Venus::Map - Map Class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | =head1 ABSTRACT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | Map Class for Perl 5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | my $map = Venus::Map->new({1..8}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | # $map->count; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | # 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | This package provides a representation of a collection of ordered key/value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | pairs and methods for validating and manipulating it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | =head1 ATTRIBUTES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | This package has the following attributes: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | =head2 accept | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | accept(string $data) (string) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | The accept attribute is read-write, accepts C<(string)> values, and is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | optional. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | =item accept example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | my $map_accept = $map->accept("number"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | # "number" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | =item accept example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | # given: example-1 accept | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | my $get_accept = $map->accept; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | # "number" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | =head1 INHERITS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | This package inherits behaviors from: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | L<Venus::Kind::Utility> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | =head1 INTEGRATES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | This package integrates behaviors from: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | L<Venus::Role::Mappable> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | L<Venus::Role::Encaseable> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | This package provides the following methods: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | =head2 all | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | all(coderef $code) (boolean) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | The all method returns true if the callback returns true for all of the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | elements. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | =item all example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | my $all = $map->all(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | $_ > 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | # 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | =item all example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | my $all = $map->all(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | my ($key, $value) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | $value > 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | # 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | =head2 any | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | any(coderef $code) (boolean) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | The any method returns true if the callback returns true for any of the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | elements. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | =item any example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | my $any = $map->any(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | $_ > 4; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | =item any example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | my $any = $map->any(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | my ($key, $value) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | $value > 4; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | =head2 attest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | attest() (any) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | The attest method validates the values using the L<Venus::Assert> expression in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | the L</accept> attribute and returns the result. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | =item attest example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | my $attest = $map->attest; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | # {1..8} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | =item attest example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | $map->accept('number | object'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | my $attest = $map->attest; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | # {1..8} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | =item attest example 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | $map->accept('string'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | my $attest = $map->attest; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | # Exception! (isa Venus::Check::Error) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | =item attest example 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | $map->accept('number'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | my $attest = $map->attest; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | # {1..8} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | =head2 call | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | call(string $iterable, string $method) (any) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | The call method executes the given method (named using the first argument) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | which performs an iteration (i.e. takes a callback) and calls the method (named | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | using the second argument) on the object (or value) and returns the result of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | the iterable method. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | =item call example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | my $call = $map->call('map', 'incr'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | # [3,5,7,9] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | =item call example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | my $call = $map->call('grep', 'gt', 4); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | # [6,8] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | =head2 contains | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | contains(any $value) (boolean) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | The contains method returns true if the value provided already exists in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | map, otherwise it returns false. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | =item contains example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | my $contains = $map->contains(2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | # true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | =item contains example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | my $contains = $map->contains(0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | # false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | =head2 count | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | count() (number) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | The count method returns the number of elements within the map. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | =item count example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | my $count = $map->count; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | # 9 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | =head2 default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | default() (hashref) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | The default method returns the default value, i.e. C<{}>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | =item default example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | my $default = $map->default; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | # {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | =head2 delete | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | delete(string $key) (any) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | The delete method returns the value of the element corresponding to the key specified after | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | removing it from the map. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | =item delete example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | my $delete = $map->delete(1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | # 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | =head2 difference | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | difference(hashref | Venus::Hash | Venus::Map $data) (Venus::Map) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | The difference method returns a new map containing only the values that don't | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | exist in the source. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | =item difference example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | my $difference = $map->difference({7..10}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | # bless(..., "Venus::Map") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | # $difference->list; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | # [10] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | =item difference example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | my $difference = $map->difference(Venus::Map->new({7,8,9,10,11,12})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | # bless(..., "Venus::Map") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | # $difference->list; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | # [10, 12] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | =item difference example 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | use Venus::Hash; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | my $difference = $map->difference(Venus::Hash->new({7,8,9,10,11,12})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | # bless(..., "Venus::Map") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | # $difference->list; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | # [10, 12] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | =head2 different | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | different(hashref | Venus::Hash | Venus::Map $data) (boolean) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | The different method returns true if the values provided don't exist in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | source. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | =item different example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | my $different = $map->different({1..10}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | # true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | =item different example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | my $different = $map->different({1..8}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | # false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | =head2 each | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | each(coderef $code) (hashref) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | The each method executes a callback for each element in the map passing the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | key and value as arguments. This method can return a list of values in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | list-context. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | =item each example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | my $each = $map->each(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | [$_] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | # [[2], [4], [6], [8]] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | =item each example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | $map->set(8,7,6,5,4,3,2,1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | my $each = $map->each(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | my ($key, $value) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | [$key, $value] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | # [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | # [8, 7], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | # [6, 5], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | # [4, 3], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | # [2, 1], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1495 | # ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1499 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1500 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1501 | =head2 empty | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1502 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1503 | empty() (Venus::Hash) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1504 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1505 | The empty method drops all elements from the map. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1506 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1507 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1508 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1509 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1510 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1511 | =item empty example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1512 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1513 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1514 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1515 | my $empty = $map->empty; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1516 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1517 | # bless({}, "Venus::Map") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1518 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1519 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1520 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1521 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1522 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1523 | =head2 exists | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1524 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1525 | exists(string $key) (boolean) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1526 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1527 | The exists method returns true if the element corresponding with the key | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1528 | specified exists, otherwise it returns false. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1529 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1530 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1531 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1532 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1533 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1534 | =item exists example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1535 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1536 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1537 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1538 | my $exists = $map->exists(1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1539 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1540 | # true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1541 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1542 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1543 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1544 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1545 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1546 | =head2 first | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1547 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1548 | first() (any) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1549 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1550 | The first method returns the value of the first element. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1551 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1552 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1553 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1554 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1555 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1556 | =item first example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1557 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1558 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1559 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1560 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1561 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1562 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1563 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1564 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1565 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1566 | my $first = $map->first; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1567 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1568 | # 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1569 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1570 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1571 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1572 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1573 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1574 | =item first example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1575 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1576 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1577 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1578 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1579 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1580 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1581 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1582 | $map->set(8,7,6,5,4,3,2,1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1583 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1584 | my $first = $map->first; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1585 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1586 | # 7 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1587 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1588 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1589 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1590 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1591 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1592 | =head2 get | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1593 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1594 | get(string $key) (any) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1595 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1596 | The get method returns the value at the position specified. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1597 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1598 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1599 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1600 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1601 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1602 | =item get example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1603 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1604 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1605 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1606 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1607 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1608 | my $get = $map->get(1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1609 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1610 | # 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1611 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1612 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1613 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1614 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1615 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1616 | =item get example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1617 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1618 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1619 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1620 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1621 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1622 | my $get = $map->get(3); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1623 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1624 | # 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1625 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1626 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1627 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1628 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1629 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1630 | =head2 grep | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1631 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1632 | grep(coderef $code) (hashref) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1633 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1634 | The grep method executes a callback for each element in the array passing the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1635 | value as an argument, returning a new array reference containing the elements | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1636 | for which the returned true. This method can return a list of values in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1637 | list-context. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1638 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1639 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1640 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1641 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1642 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1643 | =item grep example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1644 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1645 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1646 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1647 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1648 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1649 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1650 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1651 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1652 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1653 | my $grep = $map->grep(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1654 | $_ > 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1655 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1656 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1657 | # [6,8] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1658 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1659 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1660 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1661 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1662 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1663 | =item grep example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1664 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1665 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1666 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1667 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1668 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1669 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1670 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1671 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1672 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1673 | my $grep = $map->grep(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1674 | my ($key, $value) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1675 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1676 | $value > 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1677 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1678 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1679 | # [6,8] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1680 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1681 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1682 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1683 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1684 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1685 | =head2 head | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1686 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1687 | head(number $size) (hashref) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1688 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1689 | The head method returns the topmost elements, limited by the desired size | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1690 | specified. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1691 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1692 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1693 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1694 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1695 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1696 | =item head example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1697 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1698 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1699 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1700 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1701 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1702 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1703 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1704 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1705 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1706 | my $head = $map->head; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1707 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1708 | # [2] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1709 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1710 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1711 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1712 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1713 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1714 | =item head example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1715 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1716 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1717 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1718 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1719 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1720 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1721 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1722 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1723 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1724 | my $head = $map->head(1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1725 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1726 | # [2] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1727 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1728 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1729 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1730 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1731 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1732 | =item head example 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1733 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1734 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1735 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1736 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1737 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1738 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1739 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1740 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1741 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1742 | my $head = $map->head(2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1743 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1744 | # [2,4] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1745 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1746 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1747 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1748 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1749 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1750 | =item head example 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1751 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1752 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1753 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1754 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1755 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1756 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1757 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1758 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1759 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1760 | my $head = $map->head(5); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1761 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1762 | # [2,4,6,8] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1763 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1764 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1765 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1766 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1767 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1768 | =item head example 5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1769 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1770 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1771 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1772 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1773 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1774 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1775 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1776 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1777 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1778 | my $head = $map->head(20); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1779 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1780 | # [2,4,6,8] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1781 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1782 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1783 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1784 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1785 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1786 | =head2 intersect | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1787 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1788 | intersect(hashref | Venus::Hash | Venus::Map $data) (boolean) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1789 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1790 | The intersect method returns true if the values provided already exist in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1791 | source. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1792 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1793 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1794 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1795 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1796 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1797 | =item intersect example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1798 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1799 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1800 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1801 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1802 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1803 | my $intersect = $map->intersect({7,8}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1804 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1805 | # true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1806 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1807 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1808 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1809 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1810 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1811 | =item intersect example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1812 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1813 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1814 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1815 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1816 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1817 | my $intersect = $map->intersect({9,10}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1818 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1819 | # false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1820 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1821 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1822 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1823 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1824 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1825 | =head2 intersection | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1826 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1827 | intersection(hashref | Venus::Hash | Venus::Map $data) (Venus::Map) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1828 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1829 | The intersection method returns a new map containing only the values that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1830 | already exist in the source. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1831 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1832 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1833 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1834 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1835 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1836 | =item intersection example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1837 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1838 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1839 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1840 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1841 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1842 | $map->push(9,10); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1843 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1844 | my $intersection = $map->intersection({9,10,11,12}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1845 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1846 | # bless(..., "Venus::Map") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1847 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1848 | # $intersection->list; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1849 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1850 | # [10] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1851 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1852 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1853 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1854 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1855 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1856 | =item intersection example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1857 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1858 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1859 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1860 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1861 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1862 | $map->push(9,10); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1863 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1864 | my $intersection = $map->intersection(Venus::Map->new({9,10,11,12})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1865 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1866 | # bless(..., "Venus::Map") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1867 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1868 | # $intersection->list; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1869 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1870 | # [10] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1871 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1872 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1873 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1874 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1875 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1876 | =item intersection example 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1877 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1878 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1879 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1880 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1881 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1882 | use Venus::Hash; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1883 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1884 | $map->push(9,10); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1885 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1886 | my $intersection = $map->intersection(Venus::Hash->new({9,10,11,12})); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1887 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1888 | # bless(..., "Venus::Map") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1889 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1890 | # $intersection->list; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1891 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1892 | # [10] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1893 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1894 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1895 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1896 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1897 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1898 | =head2 iterator | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1899 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1900 | iterator() (coderef) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1901 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1902 | The iterator method returns a code reference which can be used to iterate over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1903 | the array. Each time the iterator is executed it will return the next element | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1904 | in the array until all elements have been seen, at which point the iterator | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1905 | will return an undefined value. This method can return a tuple with the key and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1906 | value in list-context. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1907 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1908 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1909 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1910 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1911 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1912 | =item iterator example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1913 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1914 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1915 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1916 | my $iterator = $map->iterator; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1917 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1918 | # sub { ... } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1919 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1920 | # while (my $value = $iterator->()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1921 | # say $value; # 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1922 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1923 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1924 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1925 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1926 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1927 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1928 | =item iterator example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1929 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1930 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1931 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1932 | my $iterator = $map->iterator; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1933 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1934 | # sub { ... } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1935 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1936 | # while (grep defined, my ($key, $value) = $iterator->()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1937 | # say $value; # 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1938 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1939 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1940 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1941 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1942 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1943 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1944 | =head2 join | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1945 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1946 | join(string $seperator) (string) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1947 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1948 | The join method returns a string consisting of all the elements in the array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1949 | joined by the join-string specified by the argument. Note: If the argument is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1950 | omitted, an empty string will be used as the join-string. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1951 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1952 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1953 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1954 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1955 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1956 | =item join example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1957 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1958 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1959 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1960 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1961 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1962 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1963 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1964 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1965 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1966 | my $join = $map->join; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1967 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1968 | # 2468 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1969 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1970 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1971 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1972 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1973 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1974 | =item join example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1975 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1976 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1977 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1978 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1979 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1980 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1981 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1982 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1983 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1984 | my $join = $map->join(', '); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1985 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1986 | # "2, 4, 6, 8" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1987 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1988 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1989 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1990 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1991 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1992 | =head2 keys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1993 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1994 | keys() (hashref) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1995 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1996 | The keys method returns an array reference consisting of the indicies of the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1997 | array. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1998 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1999 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2000 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2001 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2002 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2003 | =item keys example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2004 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2005 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2006 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2007 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2008 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2009 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2010 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2011 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2012 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2013 | my $keys = $map->keys; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2014 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2015 | # [1,3,5,7] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2016 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2017 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2018 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2019 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2020 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2021 | =head2 last | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2022 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2023 | last() (any) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2024 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2025 | The last method returns the value of the last element in the array. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2026 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2027 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2028 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2029 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2030 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2031 | =item last example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2032 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2033 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2034 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2035 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2036 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2037 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2038 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2039 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2040 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2041 | my $last = $map->last; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2042 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2043 | # 8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2044 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2045 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2046 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2047 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2048 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2049 | =head2 length | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2050 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2051 | length() (number) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2052 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2053 | The length method returns the number of elements within the array, and is an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2054 | alias for the L</count> method. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2055 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2056 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2057 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2058 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2059 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2060 | =item length example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2061 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2062 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2063 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2064 | my $length = $map->length; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2065 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2066 | # 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2067 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2068 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2069 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2070 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2071 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2072 | =head2 list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2073 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2074 | list() (any) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2075 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2076 | The list method returns a shallow copy of the underlying array reference as an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2077 | array reference. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2078 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2079 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2080 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2081 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2082 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2083 | =item list example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2084 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2085 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2086 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2087 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2088 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2089 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2090 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2091 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2092 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2093 | my $list = $map->list; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2094 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2095 | # 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2096 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2097 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2098 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2099 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2101 | =item list example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2103 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2105 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2107 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2109 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2111 | my @list = $map->list; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2113 | # (2,4,6,8) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2115 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2117 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2119 | =head2 map | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2121 | map(coderef $code) (hashref) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2123 | The map method iterates over each element in the array, executing the code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2124 | reference supplied in the argument, passing the routine the value at the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2125 | current position in the loop and returning a new array reference containing the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2126 | elements for which the argument returns a value or non-empty list. This method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2127 | can return a list of values in list-context. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2129 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2131 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2133 | =item map example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2135 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2137 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2139 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2141 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2143 | my $result = $map->map(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2144 | $_ * 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2145 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2147 | # [4,8,12,16] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2149 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2151 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2153 | =item map example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2155 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2157 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2159 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2161 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2163 | my $result = $map->map(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2164 | my ($key, $value) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2166 | [$key, ($value * 2)] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2167 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2169 | # [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2170 | # [1, 4], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2171 | # [3, 8], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2172 | # [5, 12], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2173 | # [7, 16], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2174 | # ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2176 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2178 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2180 | =head2 merge | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2182 | merge(any @data) (Venus::Map) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2184 | The merge method merges the arguments provided with the existing map. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2186 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2188 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2190 | =item merge example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2192 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2194 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2196 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2198 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2200 | my $merge = $map->merge(7..10); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2202 | # bless(..., "Venus::Map") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2204 | # $map->list; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2206 | # [2,4,6,8,10] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2208 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2210 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2212 | =item merge example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2214 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2216 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2218 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2220 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2222 | my $merge = $map->merge(Venus::Map->new->do('set', 5..10)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2224 | # bless(..., "Venus::Map") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2226 | # $map->list; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2228 | # [2,4,6,8,10] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2230 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2232 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2234 | =head2 new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2236 | new(any @args) (Venus::Map) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2238 | The new method constructs an instance of the package. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2240 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2242 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2244 | =item new example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2246 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2248 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2250 | my $new = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2252 | # bless(..., "Venus::Map") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2254 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2256 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2257 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2258 | =item new example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2259 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2260 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2261 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2262 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2264 | my $new = Venus::Map->new({1..8}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2266 | # bless(..., "Venus::Map") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2268 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2270 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2272 | =item new example 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2274 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2276 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2278 | my $new = Venus::Map->new(value => {1..8}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2280 | # bless(..., "Venus::Map") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2282 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2284 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2286 | =head2 none | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2288 | none(coderef $code) (boolean) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2290 | The none method returns true if none of the elements in the array meet the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2291 | criteria set by the operand and rvalue. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2293 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2295 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2297 | =item none example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2299 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2301 | my $none = $map->none(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2302 | $_ < 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2303 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2305 | # 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2307 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2309 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2310 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2311 | =item none example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2313 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2314 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2315 | my $none = $map->none(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2316 | my ($key, $value) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2317 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2318 | $value < 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2319 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2321 | # 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2323 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2325 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2327 | =head2 one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2329 | one(coderef $code) (boolean) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2330 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2331 | The one method returns true if only one of the elements in the array meet the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2332 | criteria set by the operand and rvalue. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2334 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2336 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2338 | =item one example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2340 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2342 | my $one = $map->one(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2343 | $_ == 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2344 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2345 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2346 | # 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2347 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2348 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2350 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2352 | =item one example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2354 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2356 | my $one = $map->one(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2357 | my ($key, $value) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2359 | $value == 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2360 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2362 | # 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2364 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2365 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2366 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2367 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2368 | =head2 order | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2370 | order(number @indices) (Venus::Map) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2372 | The order method reorders the array items based on the indices provided and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2373 | returns the invocant. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2375 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2377 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2379 | =item order example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2381 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2383 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2385 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2386 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2387 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2389 | my $order = $map->order; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2391 | # bless(..., "Venus::Map") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2393 | # $map->keys; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2395 | # [1,3,5,7] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2396 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2397 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2399 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2400 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2401 | =item order example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2403 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2404 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2405 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2407 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2408 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2409 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2410 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2411 | my $order = $map->order(5,3); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2413 | # bless(..., "Venus::Map") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2414 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2415 | # $map->keys; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2417 | # [5,3,1,7] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2419 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2420 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2421 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2422 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2423 | =item order example 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2424 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2425 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2426 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2427 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2428 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2429 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2430 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2431 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2433 | my $order = $map->order(7); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2434 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2435 | # bless(..., "Venus::Map") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2437 | # $map->keys; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2438 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2439 | # [7,1,3,5] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2440 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2441 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2443 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2444 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2445 | =head2 pairs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2446 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2447 | pairs() (hashref) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2448 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2449 | The pairs method is an alias to the pairs_array method. This method can return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2450 | a list of values in list-context. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2452 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2453 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2454 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2455 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2456 | =item pairs example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2458 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2460 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2461 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2462 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2463 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2464 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2465 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2466 | my $pairs = $map->pairs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2467 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2468 | # [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2469 | # [1, 2], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2470 | # [3, 4], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2471 | # [5, 6], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2472 | # [7, 8], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2473 | # ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2474 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2475 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2476 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2477 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2479 | =head2 part | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2480 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2481 | part(coderef $code) (tuple[hashref, hashref]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2482 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2483 | The part method iterates over each element in the array, executing the code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2484 | reference supplied in the argument, using the result of the code reference to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2485 | partition to array into two distinct array references. This method can return a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2486 | list of values in list-context. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2488 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2489 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2490 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2491 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2492 | =item part example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2493 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2494 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2495 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2496 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2497 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2498 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2499 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2500 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2501 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2502 | my $part = $map->part(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2503 | $_ > 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2504 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2505 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2506 | # [{5..8}, {1..4}] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2507 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2508 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2509 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2510 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2511 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2512 | =item part example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2513 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2514 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2515 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2516 | my $part = $map->part(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2517 | my ($key, $value) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2518 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2519 | $value < 5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2520 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2521 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2522 | # [{1..4}, {5..8}] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2523 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2524 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2525 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2526 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2527 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2528 | =head2 pop | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2529 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2530 | pop() (any) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2531 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2532 | The pop method returns the last element of the array shortening it by one. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2533 | Note, this method modifies the array. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2534 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2535 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2536 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2537 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2538 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2539 | =item pop example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2540 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2541 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2542 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2543 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2544 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2545 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2546 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2547 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2548 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2549 | my $pop = $map->pop; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2550 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2551 | # 8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2552 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2553 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2554 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2555 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2556 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2557 | =head2 push | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2559 | push(any @data) (hashref) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2560 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2561 | The push method appends the array by pushing the agruments onto it and returns | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2562 | itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2563 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2564 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2565 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2566 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2567 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2568 | =item push example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2569 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2570 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2571 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2572 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2573 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2574 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2575 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2576 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2577 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2578 | my $push = $map->push(9,10); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2579 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2580 | # {1..10} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2581 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2582 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2583 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2584 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2585 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2586 | =head2 random | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2587 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2588 | random() (any) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2589 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2590 | The random method returns a random element from the array. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2591 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2592 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2593 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2594 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2595 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2596 | =item random example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2597 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2598 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2599 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2600 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2601 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2602 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2603 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2604 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2605 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2606 | my $random = $map->random; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2607 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2608 | # 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2609 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2610 | # my $random = $map->random; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2611 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2612 | # 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2613 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2614 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2615 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2616 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2617 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2618 | =head2 range | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2619 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2620 | range(number | string @args) (hashref) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2621 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2622 | The range method accepts a I<"range expression"> and returns the result of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2623 | calling the L</slice> method with the computed range. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2624 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2625 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2626 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2627 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2628 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2629 | =item range example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2630 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2631 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2632 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2633 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2634 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2635 | my $range = $map->range; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2636 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2637 | # [] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2638 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2639 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2640 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2641 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2642 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2643 | =item range example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2644 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2645 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2646 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2647 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2648 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2649 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2650 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2651 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2652 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2653 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2654 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2655 | my $range = $map->range(0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2656 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2657 | # [2] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2658 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2659 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2660 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2661 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2662 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2663 | =item range example 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2664 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2665 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2666 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2667 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2668 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2669 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2670 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2671 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2672 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2673 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2674 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2675 | my $range = $map->range('0:'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2676 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2677 | # [2,4,6,8] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2678 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2679 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2680 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2681 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2682 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2683 | =item range example 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2684 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2685 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2686 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2687 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2688 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2689 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2690 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2691 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2692 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2693 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2694 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2695 | my $range = $map->range(':2'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2696 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2697 | # [2,4,6] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2698 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2699 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2700 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2701 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2702 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2703 | =item range example 5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2704 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2705 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2706 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2707 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2708 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2709 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2710 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2711 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2712 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2713 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2714 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2715 | my $range = $map->range('3:'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2716 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2717 | # [8] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2718 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2719 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2720 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2721 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2722 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2723 | =item range example 6 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2724 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2725 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2726 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2727 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2728 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2729 | my $range = $map->range('4:'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2730 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2731 | # [] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2732 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2733 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2734 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2735 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2736 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2737 | =item range example 7 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2738 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2739 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2740 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2741 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2742 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2743 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2744 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2745 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2746 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2747 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2748 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2749 | my $range = $map->range('0:1'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2750 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2751 | # [2,4] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2752 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2753 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2754 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2755 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2756 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2757 | =item range example 8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2758 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2759 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2760 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2761 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2762 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2763 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2764 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2765 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2766 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2767 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2768 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2769 | my $range = $map->range('2:4'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2770 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2771 | # [6,8] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2772 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2773 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2774 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2775 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2776 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2777 | =item range example 9 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2778 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2779 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2780 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2781 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2782 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2783 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2784 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2785 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2786 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2787 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2788 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2789 | my $range = $map->range(0..2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2790 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2791 | # [2,4,6] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2792 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2793 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2794 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2795 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2796 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2797 | =item range example 10 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2798 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2799 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2800 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2801 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2802 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2803 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2804 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2805 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2806 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2807 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2808 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2809 | my $range = $map->range('-1:3'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2810 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2811 | # [8] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2812 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2813 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2814 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2815 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2816 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2817 | =item range example 11 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2818 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2819 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2820 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2821 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2822 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2823 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2824 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2825 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2826 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2827 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2828 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2829 | my $range = $map->range('0:4'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2830 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2831 | # [2,4,6,8] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2832 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2833 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2834 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2835 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2836 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2837 | =item range example 12 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2838 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2839 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2840 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2841 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2842 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2843 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2844 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2845 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2846 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2847 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2848 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2849 | my $range = $map->range('0:-2'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2850 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2851 | # [2,4,6] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2852 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2853 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2854 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2855 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2856 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2857 | =item range example 13 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2858 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2859 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2860 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2861 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2862 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2863 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2864 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2865 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2866 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2867 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2868 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2869 | my $range = $map->range('-2:-2'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2870 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2871 | # [6] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2872 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2873 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2874 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2875 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2876 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2877 | =item range example 14 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2878 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2879 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2880 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2881 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2882 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2883 | my $range = $map->range('0:-20'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2884 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2885 | # [] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2886 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2887 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2888 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2889 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2890 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2891 | =item range example 15 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2892 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2893 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2894 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2895 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2896 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2897 | my $range = $map->range('-2:-20'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2898 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2899 | # [] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2900 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2901 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2902 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2903 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2904 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2905 | =item range example 16 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2906 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2907 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2908 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2909 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2910 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2911 | my $range = $map->range('-2:-6'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2912 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2913 | # [] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2914 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2915 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2916 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2917 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2918 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2919 | =item range example 17 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2920 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2921 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2922 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2923 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2924 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2925 | my $range = $map->range('-2:-8'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2926 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2927 | # [] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2928 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2929 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2930 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2931 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2932 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2933 | =item range example 18 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2934 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2935 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2936 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2937 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2938 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2939 | my $range = $map->range('-2:-9'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2940 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2941 | # [] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2942 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2943 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2944 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2945 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2946 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2947 | =item range example 19 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2948 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2949 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2950 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2951 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2952 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2953 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2954 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2955 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2956 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2957 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2958 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2959 | my $range = $map->range('-4:-1'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2960 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2961 | # [2,4,6,8] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2962 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2963 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2964 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2965 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2966 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2967 | =head2 reverse | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2968 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2969 | reverse() (arrayref) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2970 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2971 | The reverse method returns an array reference containing the elements in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2972 | array in reverse order. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2973 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2974 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2975 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2976 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2977 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2978 | =item reverse example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2979 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2980 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2981 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2982 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2983 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2984 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2985 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2986 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2987 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2988 | my $reverse = $map->reverse; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2989 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2990 | # [8,6,4,2] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2991 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2992 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2993 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2994 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2995 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2996 | =head2 rotate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2997 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2998 | rotate() (arrayref) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2999 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3000 | The rotate method rotates the elements in the array such that first elements | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3001 | becomes the last element and the second element becomes the first element each | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3002 | time this method is called. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3003 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3004 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3005 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3006 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3007 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3008 | =item rotate example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3009 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3010 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3011 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3012 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3013 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3014 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3015 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3016 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3017 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3018 | my $rotate = $map->rotate; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3019 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3020 | # [4,6,8,2] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3021 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3022 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3023 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3024 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3025 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3026 | =head2 rsort | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3027 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3028 | rsort() (arrayref) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3029 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3030 | The rsort method returns an array reference containing the values in the array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3031 | sorted alphanumerically in reverse. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3032 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3033 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3034 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3035 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3036 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3037 | =item rsort example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3038 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3039 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3040 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3041 | my $rsort = $map->rsort; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3042 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3043 | # [8,6,4,2] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3044 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3045 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3046 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3047 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3048 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3049 | =head2 set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3050 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3051 | set(any %pairs) (hashref) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3052 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3053 | The set method inserts a new value into the map if it doesn't exist. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3054 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3055 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3056 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3057 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3058 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3059 | =item set example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3060 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3061 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3062 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3063 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3064 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3065 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3066 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3067 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3068 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3069 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3070 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3071 | $map = $map->set(9,10); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3072 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3073 | # {1..10} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3074 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3075 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3076 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3077 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3078 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3079 | =item set example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3080 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3081 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3082 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3083 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3084 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3085 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3086 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3087 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3088 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3089 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3090 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3091 | $map = $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3092 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3093 | # {1..8} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3094 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3095 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3096 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3097 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3098 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3099 | =head2 shift | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3101 | shift() (any) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3103 | The shift method returns the first element of the array shortening it by one. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3105 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3107 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3109 | =item shift example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3111 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3113 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3115 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3117 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3119 | my $shift = $map->shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3121 | # 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3123 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3125 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3127 | =head2 shuffle | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3129 | shuffle() (arrayref) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3131 | The shuffle method returns an array with the values returned in a randomized order. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3133 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3135 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3137 | =item shuffle example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3139 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3141 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3143 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3145 | $map->set(1..20); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3147 | my $shuffle = $map->shuffle; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3149 | # [6, 12, 2, 20, 18, 16, 10, 4, 8, 14] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3151 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3153 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3155 | =head2 slice | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3157 | slice(string @keys) (hashref) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3159 | The slice method returns a hash reference containing the elements in the array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3160 | at the positions specified in the arguments. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3162 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3164 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3166 | =item slice example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3168 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3170 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3172 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3174 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3176 | my $slice = $map->slice(0, 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3178 | # [2, 4] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3180 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3182 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3184 | =item slice example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3186 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3188 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3190 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3192 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3194 | my $slice = $map->slice(3, 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3196 | # [8, 4] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3198 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3200 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3202 | =head2 sort | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3204 | sort() (hashref) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3206 | The sort method returns an array reference containing the values in the array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3207 | sorted alphanumerically. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3209 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3211 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3213 | =item sort example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3215 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3217 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3219 | my $map = Venus::Map->new({1 => 'a', 2 => 'b', 3 => 'c', 4 => 'd'}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3221 | my $sort = $map->sort; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3223 | # ["a".."d"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3225 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3227 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3229 | =head2 subset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3231 | subset(hashref | Venus::Hash | Venus::Map $data) (boolean) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3233 | The subset method returns true if all the values provided already exist in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3234 | source. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3236 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3238 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3240 | =item subset example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3242 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3244 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3246 | my $subset = $map->subset({1..6}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3248 | # true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3250 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3251 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3252 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3254 | =item subset example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3256 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3257 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3258 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3259 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3260 | my $subset = $map->subset({1..10}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3261 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3262 | # false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3264 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3266 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3268 | =item subset example 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3270 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3272 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3274 | my $subset = $map->subset({1,2}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3276 | # true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3278 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3280 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3282 | =head2 superset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3284 | superset(hashref | Venus::Hash | Venus::Map $data) (boolean) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3286 | The superset method returns true if all the values in the source exists in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3287 | values provided. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3289 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3291 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3293 | =item superset example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3295 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3297 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3299 | my $superset = $map->superset({1..10}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3301 | # true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3303 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3305 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3307 | =item superset example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3309 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3310 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3311 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3313 | my $superset = $map->superset({1..6}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3314 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3315 | # false | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3316 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3317 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3319 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3321 | =item superset example 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3323 | # given: synopsis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3325 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3327 | my $superset = $map->superset({1..8}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3329 | # true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3330 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3331 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3332 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3333 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3335 | =head2 tail | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3337 | tail(number $size) (hashref) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3338 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3339 | The tail method returns the bottommost elements, limited by the desired size | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3340 | specified. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3342 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3344 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3345 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3346 | =item tail example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3347 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3348 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3350 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3352 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3354 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3356 | my $tail = $map->tail; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3358 | # [8] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3359 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3360 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3362 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3364 | =item tail example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3365 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3366 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3367 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3368 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3370 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3372 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3374 | my $tail = $map->tail(1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3375 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3376 | # [8] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3377 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3378 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3379 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3380 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3381 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3382 | =item tail example 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3383 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3384 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3385 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3386 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3388 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3389 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3390 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3391 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3392 | my $tail = $map->tail(2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3394 | # [6,8] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3395 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3396 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3398 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3399 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3400 | =item tail example 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3402 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3404 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3405 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3406 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3407 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3408 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3410 | my $tail = $map->tail(4); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3411 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3412 | # [2,4,6,8] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3414 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3416 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3417 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3418 | =item tail example 5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3419 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3420 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3422 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3423 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3424 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3425 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3426 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3427 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3428 | my $tail = $map->tail(20); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3429 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3430 | # [2,4,6,8] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3432 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3433 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3434 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3435 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3436 | =head2 unshift | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3437 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3438 | unshift(any @data) (hashref) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3439 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3440 | The unshift method prepends the array by pushing the agruments onto it and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3441 | returns itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3443 | I<Since C<4.11>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3444 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3445 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3446 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3447 | =item unshift example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3448 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3449 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3450 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3451 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3452 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3453 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3454 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3455 | $map->set(1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3456 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3457 | my $unshift = $map->unshift(9,10,11,12); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3458 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3459 | # {1..12} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3461 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3462 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3463 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3464 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3465 | =item unshift example 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3466 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3467 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3468 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3469 | use Venus::Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3471 | my $map = Venus::Map->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3472 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3473 | $map->do('set', 1..8); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3474 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3475 | # my $unshift = $map->unshift(9,10,11,12); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3476 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3477 | # {1..12} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3479 | # $map->keys; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3480 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3481 | # [9,11,1,3,5,7] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3482 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3483 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3484 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3485 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3486 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3487 | =head2 values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3488 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3489 | values() (arrayref) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3490 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3491 | The values method returns an array reference consisting of all the values in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3492 | the hash. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3493 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3494 | I<Since C<4.15>> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3495 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3496 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3497 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3498 | =item values example 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3499 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3500 | # given: synopsis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3501 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3502 | my $values = $map->values; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3503 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3504 | # [2, 4, 6, 8] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3505 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3506 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3507 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3508 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3509 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3510 | =head1 AUTHORS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3511 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3512 | Awncorp, C<awncorp@cpan.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3513 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3514 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3515 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3516 | =head1 LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3517 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3518 | Copyright (C) 2022, Awncorp, C<awncorp@cpan.org>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3519 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3520 | This program is free software, you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3521 | the terms of the Apache license version 2.0. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3522 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3523 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||