Algorithm-SkipList

 view release on metacpan or  search on metacpan

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

    MAXLEVEL  => MAX_LEVEL,             # absolute maximum level
    P         => 0,                     # probability for each level
    K         => 0,                     # minimum power of P
    P_LEVELS  => [ ],                   # array used by random_level
    LIST_END  => undef,                 # node with greatest key
    LASTKEY   => undef,                 # last key used by next_key
    LASTINSRT => undef,                 # cached insertion fingers
    DUPLICATES => 0,                    # allow duplicates?
  };

  bless $self, $class;

  $self->_set_p( DEF_P ); # initializes P_LEVELS
  $self->_set_k( DEF_K );

  if (@_) {
    my %args = @_;
    foreach my $arg_name (CORE::keys %args) {
      my $method = "_set_" . $arg_name;
      if ($self->can($method)) {
	$self->$method( $args{ $arg_name } );

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


our $VERSION = '1.02';

# $VERSION = eval $VERSION;

use enum qw( HEADER=0 KEY VALUE );

sub new {
  my ($class, $key, $value, $hdr) = @_;
  my $self  = [ ($hdr || [ ]), $key, $value ];
  bless $self, $class;
}

sub header {
  my ($self, $hdr) = @_;
  $self->[HEADER];
}

# sub prev {
#   my ($self, $prev) = @_;
#   return (@_ > 1) ? ( $self->[PREV] = $prev ) : $self->[PREV];



( run in 0.422 second using v1.01-cache-2.11-cpan-de7293f3b23 )