Data-XHash

 view release on metacpan or  search on metacpan

lib/Data/XHash.pm  view on Meta::CPAN

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use subs qw/clear delete exists fetch first_key next_key
  scalar store xhash xhashref/;
use Carp;
use Scalar::Util qw/blessed/;
 
our @EXPORT_OK = (qw/&xhash &xhashref &xh &xhn &xhr &xhrn/);
 
# XHash values are stored internally using a ring doubly-linked with
# unweakened references:
# {hash}{$key} => [$previous_link, $next_link, $value, $key]
 
=head1 NAME
 
Data::XHash - Extended, ordered hash (commonly known as an associative array
or map) with key-path traversal and automatic index keys
 
=head1 VERSION
 
Version 0.09

lib/Data/XHash.pm  view on Meta::CPAN

380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
Clear returns the XHash tiedref or object (whichever was used).
 
=cut
 
sub CLEAR {
    my ($this) = @_;
    my $self = tied(%$this) || $this;
 
    if ($self->{hash}) {
        # Blow away unweakened refs before tossing the hash.
        @$_ = () foreach (values %{$self->{hash}});
    }
    $self->{hash} = {};
    delete $self->{tail};
    delete $self->{iter};
    $self->{max_index} = -1;
    return $this;
}
 
*clear = \&CLEAR;



( run in 0.218 second using v1.01-cache-2.11-cpan-bb97c1e446a )