16 Aug 2014 03:37:57 UTC
- Distribution: Data-BitStream
- Module version: 0.08
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (0)
- Testers (652 / 0 / 0)
- KwaliteeBus factor: 1
- 78.88% Coverage
- License: perl_5
- Perl: v5.6.2
- Activity24 month
- Download (108.2KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version
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);
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_unaryare 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.
A private Bit::Vector object.
- after erase
Resizes the vector to 0.
- after write_close
Resizes the vector to the actual length.
These methods have custom implementations.
The following roles are included.
Dana Jacobsen <email@example.com>
Copyright 2011 by Dana Jacobsen <firstname.lastname@example.org>
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Module Install Instructions
To install Data::BitStream, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Data::BitStream
For more information on module installation, please visit the detailed CPAN module installation guide.