Cache::Memory::HeapElem - wrapper for Heap::Elem that stores keys


Cache documentation Contained in the Cache distribution.

Index


Code Index:

NAME

Top

Cache::Memory::HeapElem - wrapper for Heap::Elem that stores keys

DESCRIPTION

Top

For internal use by Cache::Memory only.

SEE ALSO

Top

Cache::Memory

AUTHOR

Top

 Chris Leishman <chris@leishman.org>
 Based on work by DeWitt Clinton <dewitt@unto.net>

COPYRIGHT

Top


Cache documentation Contained in the Cache distribution.
package Cache::Memory::HeapElem;

require 5.006;
use strict;
use warnings;
use Heap::Elem;
our @ISA = qw(Heap::Elem);

sub new {
    my $class = shift;
    my ($namespace, $key, $value) = @_;
    return bless [ $value, $namespace, $key, undef ], $class;
}

sub val {
    my $self = shift;
    return @_ ? ($self->[0] = shift) : $self->[0];
}

sub namespace {
    my $self = shift;
    return $self->[1];
}

sub key {
    my $self = shift;
    return $self->[2];
}

sub heap {
    my $self = shift;
    return @_ ? ($self->[3] = shift) : $self->[3];
}

sub cmp {
    my $self = shift;
    my $other = shift;
    return $self->[0] <=> $other->[0];
}


1;
__END__