Algorithm-SkipList

 view release on metacpan or  search on metacpan

lib/Algorithm/SkipList.pm  view on Meta::CPAN

    $list1->{LIST}     = $list2->list;
    $list1->{SIZE}     = $list2->size;
    $list1->{LIST_END} = $list2->{LIST_END};
  }
  $list1->_adjust_level_threshold;
}

sub _node_by_index {
  my ($self, $index) = @_;

  # Bug: for some reason, change $[ does not affect this module.

#   if ($index >= $[) {
#     $index -= $[;
#   }

  if ($index < 0) {
    $index += $self->size;
  }

  if (($index < 0) || ($index >= $self->size)) {
    carp "index out of range", if (warnings::enabled);
    return;
  }

t/09-index.t  view on Meta::CPAN

    my $node = $List->_node_by_index($index);
    ok($node, 'negative ranges');
    ok($node->key_cmp( $List->key_by_index($index) ) == 0);
    ok($node->key_cmp( $List->last_key ) == 0);
    ok($List->value_by_index($index) == ($List->size+1+$_));
  }
}


# {
#   $[ = 1;

#   foreach (1..$List->size) {
#     my $index = $_;
#     my $node = $List->_node_by_index($index);
#     ok($node);
#     ok($node->key_cmp( $List->key_by_index($index) ) == 0);
#     ok($List->value_by_index($index) == $_);
#   }

#   foreach ((-$List->size)..-1) {



( run in 0.387 second using v1.01-cache-2.11-cpan-cc502c75498 )