App-SimpleBackuper

 view release on metacpan or  search on metacpan

local/lib/perl5/Tie/IxHash.pm  view on Meta::CPAN


=head1 SYNOPSIS

    # simple usage
    use Tie::IxHash;
    tie HASHVARIABLE, 'Tie::IxHash' [, LIST];

    # OO interface with more powerful features
    use Tie::IxHash;
    TIEOBJECT = Tie::IxHash->new( [LIST] );
    TIEOBJECT->Splice( OFFSET [, LENGTH [, LIST]] );
    TIEOBJECT->Push( LIST );
    TIEOBJECT->Pop;
    TIEOBJECT->Shift;
    TIEOBJECT->Unshift( LIST );
    TIEOBJECT->Keys( [LIST] );
    TIEOBJECT->Values( [LIST] );
    TIEOBJECT->Indices( LIST );
    TIEOBJECT->Delete( [LIST] );
    TIEOBJECT->Replace( OFFSET, VALUE, [KEY] );
    TIEOBJECT->Reorder( LIST );
    TIEOBJECT->SortByKey;
    TIEOBJECT->SortByValue;
    TIEOBJECT->Length;


=head1 DESCRIPTION

This Perl module implements Perl hashes that preserve the order in which the
hash elements were added.  The order is not affected when values
corresponding to existing keys in the IxHash are changed.  The elements can
also be set to any arbitrary supplied order.  The familiar perl array
operations can also be performed on the IxHash.


=head2 Standard C<TIEHASH> Interface

The standard C<TIEHASH> mechanism is available. This interface is 
recommended for simple uses, since the usage is exactly the same as
regular Perl hashes after the C<tie> is declared.


=head2 Object Interface

This module also provides an extended object-oriented interface that can be
used for more powerful operations with the IxHash.  The following methods
are available:

=over 8

=item FETCH, STORE, DELETE, EXISTS

These standard C<TIEHASH> methods mandated by Perl can be used directly.
See the C<tie> entry in perlfunc(1) for details.

=item Push, Pop, Shift, Unshift, Splice

These additional methods resembling Perl functions are available for
operating on key-value pairs in the IxHash. The behavior is the same as the
corresponding perl functions, except when a supplied hash key already exists
in the hash. In that case, the existing value is updated but its order is
not affected.  To unconditionally alter the order of a supplied key-value
pair, first C<DELETE> the IxHash element.

=item Keys

Returns an array of IxHash element keys corresponding to the list of supplied
indices.  Returns an array of all the keys if called without arguments.
Note the return value is mostly only useful when used in a list context
(since perl will convert it to the number of elements in the array when
used in a scalar context, and that may not be very useful).

If a single argument is given, returns the single key corresponding to
the index.  This is usable in either scalar or list context.

=item Values

Returns an array of IxHash element values corresponding to the list of supplied
indices.  Returns an array of all the values if called without arguments.
Note the return value is mostly only useful when used in a list context
(since perl will convert it to the number of elements in the array when
used in a scalar context, and that may not be very useful).

If a single argument is given, returns the single value corresponding to
the index.  This is usable in either scalar or list context.

=item Indices

Returns an array of indices corresponding to the supplied list of keys.
Note the return value is mostly only useful when used in a list context
(since perl will convert it to the number of elements in the array when
used in a scalar context, and that may not be very useful).

If a single argument is given, returns the single index corresponding to
the key.  This is usable in either scalar or list context.

=item Delete

Removes elements with the supplied keys from the IxHash.

=item Replace

Substitutes the IxHash element at the specified index with the supplied
value-key pair.  If a key is not supplied, simply substitutes the value at
index with the supplied value. If an element with the supplied key already
exists, it will be removed from the IxHash first.

=item Reorder

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.



( run in 0.588 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )