Data-BitStream
view release on metacpan or search on metacpan
lib/Data/BitStream/BLVec.pm view on Meta::CPAN
my $self = $_[0];
# data comes in 2nd argument
my $bits = $_[2] || 8*length($_[1]);
$self->write_open;
my $vref = $self->_vec;
$vref->from_raw($_[1], $bits);
$self->_setlen( $bits );
$self->rewind_for_read;
}
sub put_stream {
my $self = shift;
my $source = shift;
my $vref = $self->_vec;
if (ref $source eq __PACKAGE__) {
$vref->put_stream($source->_vec);
} else {
$vref->put_stream($source);
}
$self->_setlen( $vref->len );
1;
}
# default everything else
__PACKAGE__->meta->make_immutable;
no Moo;
1;
# ABSTRACT: An XS-wrapper implementation of Data::BitStream
=pod
=head1 NAME
Data::BitStream::BLVec - An XS-wrapper implementation of Data::BitStream
=head1 SYNOPSIS
use Data::BitStream::BLVec;
my $stream = Data::BitStream::BLVec->new;
$stream->put_gamma($_) for (1 .. 20);
$stream->rewind_for_read;
my @values = $stream->get_gamma(-1);
=head1 DESCRIPTION
An implementation of L<Data::BitStream>. See the documentation for that
module for many more examples, and L<Data::BitStream::Base> for the API.
This document only describes the unique features of this implementation,
which is of limited value to people purely using L<Data::BitStream>.
This implementation points everything to the implementations in
Data::BitStream::XS where possible. This gives the majority of the performance
benefit of the XS module, while (1) transparently applying the speedup through
the Data::BitStream package, and (2) allowing all the Moo/Mouse/Moose extensions
and extra roles to be used while still retaining high performance at the core.
This is the default L<Data::BitStream> implementation if Data::BitStream::XS
is installed.
=head2 DATA
=over 4
=item B< _vec >
A private Data::BitStream::XS object.
=back
=head2 CLASS METHODS
=over 4
=item I<after> B< erase >
=item I<after> B< rewind >
=item I<after> B< read_open >
=item I<after> B< write_open >
=item I<after> B< write_close >
Applies the appropriate behavior to the XS object.
=item B< read >
=item B< write >
=item B< put_string >
=item B< read_string >
=item B< to_raw >
=item B< put_raw >
=item B< from_raw >
=item B< put_stream >
These methods have custom implementations.
The following codes have C<get_> and C<put_> methods:
unary
unary1
gamma
( run in 1.615 second using v1.01-cache-2.11-cpan-d7f47b0818f )