Algorithm-BreakOverlappingRectangles
view release on metacpan or search on metacpan
lib/Algorithm/BreakOverlappingRectangles.pm view on Meta::CPAN
use constant NVSIZE => length pack F => 1.0;
use constant IDOFFSET => NVSIZE * 4;
sub new {
my $class = shift;
my $self = { rects => [],
name2id => {},
names => [],
n => 0 };
bless $self, $class;
}
sub add_rectangle {
my ($self, $x0, $y0, $x1, $y1, @names) = @_;
($x0, $x1) = ($x1, $x0) if $x0 > $x1;
($y0, $y1) = ($y1, $y0) if $y0 > $y1;
my @ids;
for (@names) {
lib/Algorithm/BreakOverlappingRectangles.pm view on Meta::CPAN
tie my @iter, 'Algorithm::BreakOverlappingRectangles::Iterator', $self;
return \@iter;
}
package Algorithm::BreakOverlappingRectangles::Iterator;
use base 'Tie::Array';
sub TIEARRAY {
my ($class, $abor) = @_;
my $self = bless \$abor, $class;
}
sub FETCH {
my ($self, $index) = @_;
my $abor = $$self;
$abor->_do_break unless $abor->{broken};
my $r = $abor->{rects}[$index];
if (defined $r) {
# print ".";
my $names = $abor->{names};
sv_2pvbyte_nolen|||
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_mg|5.004050||p
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
sv_catpvn_nomg|5.007002||p
sv_catpvn|||
( run in 1.048 second using v1.01-cache-2.11-cpan-de7293f3b23 )