Someone
public text v1 · immutable#
# Iterative insert
#
sub insert {
my($tree, $value, $children) = @_;
my $branch = $tree;
do{
unless($branch){
$branch = {};
for my $index (0 .. $children-1) { #build node
$branch->{$index} = undef;
}
$branch->{VALUE} = $value;
$_[0] = $tree;
return;
}
}while($branch = $branch->{$value % $children});
}