Git Product home page Git Product logo

bit-io's Introduction

jinahya

Domate via Paypal

Automatically exported from code.google.com/p/jinahya

bit-io's People

Contributors

cschneider avatar jinahya avatar onacit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bit-io's Issues

Optimization for Quotient and Remainder

Re:

https://github.com/jinahya/bit-io/blob/develop/src/main/java/com/github/jinahya/bit/io/AbstractBitInput.java#L116

There are a few places in the code base that use integer division and modular arithmetic. It may be possible to replace them with faster bit-shifting equivalents. Imagine a variable mPosition that points to a particular bit within a byte array. Retrieving the value of the bit can be accomplished as follows, where BYTE_INDEX_SHIFT equals 3 (i.e., log base 2 of 8):

final int byteIndex = (int) (mPosition >> BYTE_INDEX_SHIFT);
final int bitIndex = (int) (mPosition - (byteIndex << BYTE_INDEX_SHIFT));

final int bitShifts = Byte.SIZE - bitIndex - 1;
final int bit = (mSequence[byteIndex] & (1 << bitShifts)) >> bitShifts;

I suspect such calculations will be more efficient than using %, especially on older hardware.

Feature request: Skip bits

Consider adding a method that skips ahead by n bits, such as:

       final byte[] bytes = { 0b01011001, 0b01100101 };
       final ArrayByteInput byteInput = new ArrayByteInput( bytes );
       final BitInput bitInput = new DefaultBitInput( byteInput );

       bitInput.skip( 5 );

       final int i = bitInput.readInt( true, 6 );
       final boolean bo = bitInput.readBoolean();
       final byte nibble = bitInput.readByte( true, 4 ); // Or bitInput.readNybble();?

Add a flush operation, to write last octet to underlying without advancing

Great stuff, but sadly I do now miss the "flush()" that basically writes through to byte buffer without advancing the position. As I do have a concurrent read on the ByteBuffer I need all Bits also in the last octet filled (padded with 0)

I don't want to call align(8) after every write as my data consumes only 2 bits in many cases.

Feature request: Read nybble

Consider a convenience method that reads 4 bits into a byte:

final BitInput bitInput = new DefaultBitInput( ... );
final byte nybble = bitInput.readNybble();

where did the deprecated ByteInput methods move to?

Hi - nice library.

The docs show ByteInput being used with various methods like readBoolean or ints but v2.0.2 ByteInput only has a single read int method. Can you point me to the correct implementation to read bits from a byte array?

I can help with your readme once i get it working

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.