view release on metacpan or search on metacpan
AV* elem = newAV();
int idx;
CSvalueSelection vs;
cs_getNoGoodElementAt(&idx, &vs, ng, i);
av_push(elem, newSViv(idx));
av_push(elem, newSViv(vs.method));
av_push(elem, newSViv(vs.value));
r = (SV*)newRV_noinc((SV*)elem);
r = sv_bless(r, ngeh);
av_push(elements, r);
}
r = newRV_noinc((SV*)elements);
XPUSHs(sv_2mortal((SV*)r));
PUTBACK;
{
int count = call_method(meth, G_ARRAY);
SPAGAIN;
lib/Algorithm/CP/IZ.pm view on Meta::CPAN
package Algorithm::CP::IZ;
use 5.010000; # need Newx in XS
use strict;
use warnings;
use Carp;
use Scalar::Util qw(weaken blessed looks_like_number);
require Exporter;
use AutoLoader;
use Algorithm::CP::IZ::Int;
use Algorithm::CP::IZ::RefVarArray;
use Algorithm::CP::IZ::RefIntArray;
use Algorithm::CP::IZ::ParamValidator qw(validate);
use Algorithm::CP::IZ::ValueSelector;
use Algorithm::CP::IZ::CriteriaValueSelector;
lib/Algorithm/CP/IZ.pm view on Meta::CPAN
sub new {
my $class = shift;
if ($Instances > 0) {
_report_error("another instance is working.");
}
Algorithm::CP::IZ::cs_init();
$Instances++;
bless {
_vars => [],
_cxt0 => [],
_cxt => [],
_const_vars => {},
_backtracks => {},
_ref_int_arrays => {},
_ref_var_arrays => {},
}, $class;
}
lib/Algorithm/CP/IZ.pm view on Meta::CPAN
validate([$x], ["I"], "search: MaxFail must be an integer");
},
ValueSelectors => sub {
my $x = shift;
validate([$x], [
sub {
my $vs = shift;
return unless (ref $vs eq 'ARRAY'
&& scalar @$vs == scalar @$var_array);
for my $obj (@$vs) {
return unless (blessed($obj)
&& $obj->isa("Algorithm::CP::IZ::ValueSelector"));
}
1;
}], "search: ValueSelectos must be a arrayref of Algorithm::CP::IZ::ValueSelector instance for each variables");
},
MaxFailFunc => sub {
my $x = shift;
validate([$x], ["C"], "search: MaxFailFunc must be a coderef");
},
NoGoodSet => sub {
my $x = shift;
validate([$x], [
sub {
my $ngs = shift;
return blessed($ngs) && $ngs->isa("Algorithm::CP::IZ::NoGoodSet");
}], "search: NoGoodSet must be a instance of Algorithm::CP::IZ::NoGoodSet");
},
Notify => sub {
my $x = shift;
validate([$x], [
sub {
my $notify = shift;
return 1 if (ref $notify eq 'HASH');
return 1 if (blessed($notify));
return 0;
}], "search: Notify must be an hashref or object");
},
);
my @keys = sort keys %$params;
for my $k (@keys) {
if (exists $checker{$k}) {
my $func = $checker{$k};
lib/Algorithm/CP/IZ.pm view on Meta::CPAN
use Algorithm::CP::IZ qw(:value_selector);
package VSSample1;
sub new {
my $class = shift;
my ($v, $index) = @_;
my $self = {
_pos => 0,
};
bless $self, $class;
}
sub next {
my $self = shift;
my ($v, $index) = @_;
my $pos = $self->{_pos};
my $domain = $v->domain;
# return empty after enumerate all values
lib/Algorithm/CP/IZ/CriteriaValueSelector.pm view on Meta::CPAN
sort {
$map{$a} <=> $map{$b}
|| $a <=> $b;
} @$values];
my $self = {
_values => $values,
_pos => 0,
};
bless $self, $class;
}
sub next {
my $self = shift;
my ($v, $index) = @_;
my $pos = $self->{_pos};
my $values = $self->{_values};
return if ($pos >= @$values);
lib/Algorithm/CP/IZ/Int.pm view on Meta::CPAN
# get pointer value dereferencing $self
my $ret = $$self;
return "$ret";
}
sub new {
my $class = shift;
my $ptr = shift;
bless \$ptr, $class;
}
sub name {
my $self = $_[0];
my $key = $self->key;
if (@_ == 1) {
return $self->get_name;
}
lib/Algorithm/CP/IZ/Int.pm view on Meta::CPAN
validate([scalar @_, $min, $max], [sub { shift == 2 }, "I", "I"],
"Usage: NotInInterval(min, max)");
return Algorithm::CP::IZ::cs_NotInInterval($$self, int($min), int($max));
}
sub _invalidate {
my $self = shift;
bless $self, __PACKAGE__ . "::InvalidInt";
}
sub select_value {
my $self = shift;
my ($method, $value) = @_;
validate([$method, $value], ["I", "I"],
"Usage: selectValue(method, value)");
return Algorithm::CP::IZ::cs_selectValue($self, $method, $value);
}
lib/Algorithm/CP/IZ/NoGoodSet.pm view on Meta::CPAN
# this object must be created by $iz->create_no_good_set
defined($var_array) or croak "internal error";
my $parray = Algorithm::CP::IZ::RefVarArray->new($var_array);
my $self = {
_var_array => $var_array,
_parray => $parray,
_prefilter => $prefilter,
_ext => $ext,
};
bless $self, $class;
}
sub nb_no_goods {
my $self = shift;
defined($self->{_ngs}) or
croak(__PACKAGE__ . ": not initialized.");
return Algorithm::CP::IZ::cs_getNbNoGoods($self->{_ngs});
}
lib/Algorithm/CP/IZ/RefIntArray.pm view on Meta::CPAN
package Algorithm::CP::IZ::RefIntArray;
use strict;
use warnings;
sub new {
my $class = shift;
my $array = shift;
my $ptr = Algorithm::CP::IZ::alloc_int_array([map { $_+0 } @$array]);
bless \$ptr, $class;
}
sub DESTROY {
my $self = shift;
Algorithm::CP::IZ::free_array($$self);
}
1;
lib/Algorithm/CP/IZ/RefVarArray.pm view on Meta::CPAN
package Algorithm::CP::IZ::RefVarArray;
use strict;
use warnings;
sub new {
my $class = shift;
my $array = shift;
my $ptr = Algorithm::CP::IZ::alloc_var_array([map { $$_ } @$array]);
bless \$ptr, $class;
}
sub ptr {
my $self = shift;
return $$self;
}
sub DESTROY {
my $self = shift;
Algorithm::CP::IZ::free_array($$self);
lib/Algorithm/CP/IZ/SearchNotify.pm view on Meta::CPAN
found
);
sub new {
my $class = shift;
my $obj = shift;
my $self = {
};
bless $self, $class;
my $ptr = &Algorithm::CP::IZ::cs_createSearchNotify($self);
$self->{_ptr} = $ptr;
my %methods;
if (ref $obj eq 'HASH') {
for my $m (@method_names) {
if (exists $obj->{$m}) {
my $s = $obj->{$m};
unless (ref $s eq 'CODE') {
lib/Algorithm/CP/IZ/ValueSelector.pm view on Meta::CPAN
my $class = shift;
my ($iz, $id) = @_;
my $vs = Algorithm::CP::IZ::cs_getValueSelector($id);
my $self = {
_iz => $iz,
_vs => $vs,
};
bless $self, $class;
}
sub init {
my $self = shift;
my ($index, $var_array) = @_;
my $iz = $self->{_iz};
my $vs = $self->{_vs};
my $size = scalar @$var_array;
lib/Algorithm/CP/IZ/ValueSelector.pm view on Meta::CPAN
$$array, $size);
my $self = {
_vs => $vs,
_ptr => $ptr,
_index => $index,
_array => $array,
_size => $size,
};
bless $self, $class;
}
sub next {
my $self = shift;
my $vs = $self->{_vs};
my $index = $self->{_index};
my $array = $self->{_array};
my $ptr = $self->{_ptr};
my $size = $self->{_size};
lib/Algorithm/CP/IZ/ValueSelector.pm view on Meta::CPAN
my ($iz, $cls) = @_;
my $vs = Algorithm::CP::IZ::createSimpleValueSelector();
my $self = {
_iz => $iz,
_vs => $vs,
_cls => $cls,
};
bless $self, $class;
}
sub prepare {
my $self = shift;
my ($index) = @_;
# keep init in memory to avoid GC
# but don't keep $self too avoid cyclic reference
my $cls = $self->{_cls};
sv_2pvbyte_nolen|5.006000||p
sv_2pvbyte|5.006000||p
sv_2pvutf8_nolen||5.006000|
sv_2pvutf8||5.006000|
sv_2pv|||
sv_2uv_flags||5.009001|
sv_2uv|5.004000||p
sv_add_arena|||
sv_add_backref|||
sv_backoff|||
sv_bless|||
sv_cat_decode||5.008001|
sv_catpv_flags||5.013006|
sv_catpv_mg|5.004050||p
sv_catpv_nomg||5.013006|
sv_catpvf_mg_nocontext|||pvn
sv_catpvf_mg|5.006000|5.004000|pv
sv_catpvf_nocontext|||vn
sv_catpvf||5.004000|v
sv_catpvn_flags||5.007002|
sv_catpvn_mg|5.004050||p
&& $iz->IZ_VERSION_MINOR >= 6);
package TestVS1;
sub new {
my $class = shift;
my ($v, $index) = @_;
my $self = {
_pos => 0,
};
bless $self, $class;
}
sub next {
my $self = shift;
my ($v, $index) = @_;
my $pos = $self->{_pos};
my $domain = $v->domain;
return if ($pos >= @$domain);
&& $iz->IZ_VERSION_MINOR >= 6);
package TestVS2;
sub new {
my $class = shift;
my ($v, $index) = @_;
my $self = {
_pos => 0,
};
bless $self, $class;
}
sub next {
my $self = shift;
my ($v, $index) = @_;
my $pos = $self->{_pos};
my $domain = $v->domain;
return if ($pos >= @$domain);
&& $iz->IZ_VERSION_MINOR >= 6);
package TestVS3;
sub new {
my $class = shift;
my ($v, $index) = @_;
my $self = {
_pos => 0,
};
bless $self, $class;
}
sub next {
my $self = shift;
my ($v, $index) = @_;
my $pos = $self->{_pos};
my $domain = $v->domain;
return if ($pos >= @$domain);
my $func_called = 0;
my $vs = $iz->get_value_selector(&Algorithm::CP::IZ::CS_VALUE_SELECTOR_LOWER_AND_UPPER);
my $array = [$y, $s, $e, $n, $d, $m, $o, $r];
my @ng_set;
package TestNG;
sub new {
my $class = shift;
bless {}, $class;
}
sub prefilter {
my $self = shift;
my $ngs = shift;
my $ng = shift;
my $var_array = shift;
my $nElem = scalar @$ng;
push(@ng_set, $ng);
my $func_called = 0;
my $vs = $iz->get_value_selector(&Algorithm::CP::IZ::CS_VALUE_SELECTOR_LOWER_AND_UPPER);
my $array = [$y, $s, $e, $n, $d, $m, $o, $r];
my @ng_set;
package TestNG2;
sub new {
my $class = shift;
bless {}, $class;
}
sub prefilter {
my $self = shift;
my $ngs = shift;
my $ng = shift;
my $var_array = shift;
my $nElem = scalar @$ng;
return 1;
}
t/09notify.t view on Meta::CPAN
my $v1 = $iz->ScalProd([$s, $e, $n, $d], [1000, 100, 10, 1]);
my $v2 = $iz->ScalProd([$m, $o, $r, $e], [1000, 100, 10, 1]);
my $v3 = $iz->ScalProd([$m, $o, $n, $e, $y], [10000, 1000, 100, 10, 1]);
my $v4 = $iz->Add($v1, $v2);
$v3->Eq($v4);
package TestObj;
sub new {
my $class = shift;
bless {}, $class;
}
my %called;
sub search_start {
my $self = shift;
my $array = shift;
$called{search_start}++;
}