Algorithm-SkipList

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN


AUTHOR
    Robert Rothenberg <rrwo at cpan.org>

LICENSE
    Copyright (c) 2003-2005 Robert Rothenberg. All rights reserved. This
    program is free software; you can redistribute it and/or modify it
    under the same terms as Perl itself.

SEE ALSO
    See the article "A Skip List Cookbook" (William Pugh, 1989), or
    similar ones by the author at http://www.cs.umd.edu/~pugh/ which
    discuss skip lists.

    Because of the way Perl manages memory, you may be better off
    using a hash with sorted keys (such as Tie::Hash::Sorted) rather
    than maintaining a sorted dictionary using this or similar
    modules.

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

sub max_level {
  my ($self, $level) = @_;

  if (defined $level) {
    $self->_set_max_level($level);
  } else {
    $self->{MAXLEVEL};
  }
}

# We use the formula from Pugh's "Skip List Cookbook" paper.  We
# generate a reverse-sorted array of values based on p and k.  In
# _new_node_level() we look for the highest value in the array that is
# less than a random number n (0<n<1).

sub _build_distribution {
  no integer;

  my ($self) = @_;

  my $p = $self->p;

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

L<http://rt.cpan.org> to submit bug reports.

=head1 LICENSE

Copyright (c) 2003-2005 Robert Rothenberg. All rights reserved.  This
program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.

=head1 SEE ALSO

See the article by William Pugh, "A Skip List Cookbook" (1989), or
similar ones by the author at L<http://www.cs.umd.edu/~pugh/> which
discuss skip lists.

Another article worth reading is by Bruce Schneier, "Skip Lists:
They're easy to implement and they work",
L<Doctor Dobbs Journal|http://www.ddj.com>, January 1994.

L<Tie::Hash::Sorted> maintains a hash where keys are sorted.  In many
cases this is faster, uses less memory (because of the way Perl5
manages memory), and may be more appropriate for some uses.



( run in 0.606 second using v1.01-cache-2.11-cpan-e9199f4ba4c )