Config-General
view release on metacpan or search on metacpan
t/Tie/IxHash.pm view on Meta::CPAN
This method can be used to manipulate the internal order of the IxHash
elements by supplying a list of keys in the desired order. Note however,
that any IxHash elements whose keys are not in the list will be removed from
the IxHash.
=item Length
Returns the number of IxHash elements.
=item SortByKey
Reorders the IxHash elements by textual comparison of the keys.
=item SortByValue
Reorders the IxHash elements by textual comparison of the values.
=back
=head1 EXAMPLE
use Tie::IxHash;
# simple interface
$t = tie(%myhash, Tie::IxHash, 'a' => 1, 'b' => 2);
%myhash = (first => 1, second => 2, third => 3);
$myhash{fourth} = 4;
@keys = keys %myhash;
@values = values %myhash;
print("y") if exists $myhash{third};
# OO interface
$t = Tie::IxHash->new(first => 1, second => 2, third => 3);
$t->Push(fourth => 4); # same as $myhash{'fourth'} = 4;
($k, $v) = $t->Pop; # $k is 'fourth', $v is 4
$t->Unshift(neg => -1, zeroth => 0);
($k, $v) = $t->Shift; # $k is 'neg', $v is -1
@oneandtwo = $t->Splice(1, 2, foo => 100, bar => 101);
@keys = $t->Keys;
@values = $t->Values;
@indices = $t->Indices('foo', 'zeroth');
@itemkeys = $t->Keys(@indices);
@itemvals = $t->Values(@indices);
$t->Replace(2, 0.3, 'other');
$t->Delete('second', 'zeroth');
$len = $t->Length; # number of key-value pairs
$t->Reorder(reverse @keys);
$t->SortByKey;
$t->SortByValue;
=head1 BUGS
You cannot specify a negative length to C<Splice>. Negative indexes are OK,
though.
Indexing always begins at 0 (despite the current C<$[> setting) for
all the functions.
=head1 TODO
Addition of elements with keys that already exist to the end of the IxHash
must be controlled by a switch.
Provide C<TIEARRAY> interface when it stabilizes in Perl.
Rewrite using XSUBs for efficiency.
=head1 AUTHOR
Gurusamy Sarathy gsar@umich.edu
Copyright (c) 1995 Gurusamy Sarathy. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
=head1 VERSION
Version 1.21 20 Nov 1997
=head1 SEE ALSO
perl(1)
=cut
( run in 3.525 seconds using v1.01-cache-2.11-cpan-a5162978ef8 )