File: Quick.pm

package info (click to toggle)
libarray-unique-perl 0.09-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 152 kB
  • sloc: perl: 429; makefile: 9
file content (99 lines) | stat: -rw-r--r-- 1,249 bytes parent folder | download
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package Array::Unique::Quick;

use strict;
use warnings;
use Carp;

our $VERSION = '0.09';

sub _init {
    my $self = shift;

#    $self->[0] = {};
}

sub noimp {
    carp "Method not implemented\n";
}

sub CLEAR     { 
    my $self = shift;
    %$self = ();
}

sub EXTEND {
    my $self = shift;
    #?
}

sub STORE {
    my $self = shift;
    my $index = shift;
    my $value = shift;

    $self->{$value}=1;
}

sub PUSH {
    my $self = shift;

    foreach (@_) {
	$self->{$_}=1;
    }
}

sub FETCHSIZE { 
    my $self = shift;
    return scalar keys %$self;
}

sub FETCH { 
    my ($self, $index) = @_;
    return ((keys (%$self))[$index]);
}


sub STORESIZE { 
    my $self = shift;
    my $size = shift;

    # We cannot enlarge the array as the values would be undef

    # But we can make it smaller
    if ($self->FETCHSIZE > $size) {
	$self->[0]->Splice($size);
    }
}


sub SPLICE {
    my $self = shift;
    $self->noimp;
}

sub UNSHIFT {
    my $self = shift;
    $self->noimp;
#    $self->SPLICE(0,0,@_);
}

sub SHIFT {
    my $self = shift;
    $self->noimp;

#    ($self->[0]->Shift)[0];
}

sub POP {
    my $self = shift;
     $self->noimp;
#   ($self->[0]->Pop)[0];
}

1;
__END__
=pod

 See Array::Unique for documentation

=cut