Dana Jacobsen > Data-BitStream-0.07 > Data::BitStream::BitVec

Download:
Data-BitStream-0.07.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.01   Source   Latest Release: Data-BitStream-0.08

NAME ^

Data::BitStream::BitVec - A Bit::Vector implementation of Data::BitStream

SYNOPSIS ^

  use Data::BitStream::BitVec;
  my $stream = Data::BitStream::BitVec->new;
  $stream->put_gamma($_) for (1 .. 20);
  $stream->rewind_for_read;
  my @values = $stream->get_gamma(-1);

DESCRIPTION ^

An implementation of Data::BitStream. See the documentation for that module for many more examples, and 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 Data::BitStream.

This implementation uses the Bit::Vector module for internal data storage, as that module has a number of very efficient methods for manipulating vectors. However, Bit::Vector stores and accesses all its data in little-endian form, making it extremely difficult to use as a bit stream. Hence some functions such as get_unary are blazing fast, as we can use one of the nice Bit::Vector functions. Many other functions are just as difficult or more difficult to create as regular vectors, and often turn out slower.

Another interesting observation is that Bit::Vector is quite slow to resize the vector. Hence this implementation takes a rather aggressive stance in resizing, bumping up the size to 1.15 * (needed_bits + 2048) when the vector needs to grow. When the stream is closed for writing, it is resized to just the size needed.

Hence this implementation mainly serves as an example. An XS implementation of a big-endian vector would make this extremely fast.

DATA

_vec

A private Bit::Vector object.

CLASS METHODS

after erase

Resizes the vector to 0.

after write_close

Resizes the vector to the actual length.

read
write
put_unary
get_unary

These methods have custom implementations.

ROLES

The following roles are included.

Data::BitStream::Code::Base
Data::BitStream::Code::Gamma
Data::BitStream::Code::Delta
Data::BitStream::Code::Omega
Data::BitStream::Code::Levenstein
Data::BitStream::Code::EvenRodeh
Data::BitStream::Code::Fibonacci
Data::BitStream::Code::Golomb
Data::BitStream::Code::Rice
Data::BitStream::Code::GammaGolomb
Data::BitStream::Code::ExponentialGolomb
Data::BitStream::Code::StartStop
Data::BitStream::Code::Baer
Data::BitStream::Code::BoldiVigna
Data::BitStream::Code::ARice
Data::BitStream::Code::Additive
Data::BitStream::Code::Comma
Data::BitStream::Code::Taboo

SEE ALSO ^

Data::BitStream
Data::BitStream::Base
Data::BitStream::WordVec

AUTHORS ^

Dana Jacobsen <dana@acm.org>

COPYRIGHT ^

Copyright 2011 by Dana Jacobsen <dana@acm.org>

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: