Data-CompactReadonly
view release on metacpan or search on metacpan
lib/Data/CompactReadonly/V0/Dictionary.pm view on Meta::CPAN
die($@) if($@);
}
}
$node_class->_create(%args, data => $item->{data});
}
}
}
}
# Efficient binary search. Relies on elements' being ASCIIbetically sorted by key.
# 1 <= iterations to find key (or find that there is no key) <= ceil(log2(N))
# so no more than 4 iterations for a ten element list, no more than 20 for
# a million element list. Each iteration takes two seeks and two reads there
# are then two more seeks and reads to get the value
sub element {
my($self, $element) = @_;
die(
"$self: Invalid element: ".
(!defined($element) ? '[undef]' : $element).
" isn't Text or numeric\n"
) unless(defined($element) && !ref($element));
( run in 2.339 seconds using v1.01-cache-2.11-cpan-71847e10f99 )