File: HeapElem.pm

package info (click to toggle)
libcache-perl 2.11-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 428 kB
  • sloc: perl: 2,577; makefile: 2
file content (73 lines) | stat: -r--r--r-- 1,300 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
=head1 NAME

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

=head1 DESCRIPTION

For internal use by Cache::Memory only.

=cut
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__

=head1 SEE ALSO

Cache::Memory

=head1 AUTHOR

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

=head1 COPYRIGHT

 Copyright (C) 2003-2006 Chris Leishman.  All Rights Reserved.

This module is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
either expressed or implied. This program is free software; you can
redistribute or modify it under the same terms as Perl itself.

$Id: HeapElem.pm,v 1.4 2006/01/31 15:23:58 caleishm Exp $

=cut