An open API service indexing awesome lists of open source software.

https://github.com/dopsun/bbutils

java.nio.ByteBuffer related utilities.
https://github.com/dopsun/bbutils

Last synced: 5 months ago
JSON representation

java.nio.ByteBuffer related utilities.

Awesome Lists containing this project

README

          

# bbutils
[![Build Status](https://travis-ci.org/dopsun/bbutils.svg?branch=master)](https://travis-ci.org/dopsun/bbutils)

java.nio.ByteBuffer related utilities.

## Buffer, FixedBuffer and AutoBuffer
* [Buffer](bbutils/src/main/java/com/dopsun/bbutils/Buffer.java) a buffer inspired from ``java.nio.ByteBuffer``.
* [FixedBuffer](bbutils/src/main/java/com/dopsun/bbutils/FixedBuffer.java): a buffer with fixed size.
* [AutoBuffer](bbutils/src/main/java/com/dopsun/bbutils/AutoBuffer.java): a buffer grows when required.
* [Buffers](bbutils/src/main/java/com/dopsun/bbutils/Buffers.java): factory methods for ``Buffer``.

### FixedBuffer
``FixedBuffer`` is an abstraction similar to ``java.nio.ByteBuffer``. Refer to [FixedBuffer](bbutils/src/main/java/com/dopsun/bbutils/FixedBuffer.java) to find out details.

### AutoBuffer
There are 3 types of auto buffer:

* [Arithmetic Progression (AP)](https://en.wikipedia.org/wiki/Arithmetic_progression): grows following AP sequences, with initial capacity and difference.
* Factory method: ``Buffers.apAutoBuffer(Allocator allocator, int initCapacity, int difference)``
* [Geometric Progression (GP)](https://en.wikipedia.org/wiki/Geometric_progression): grows following GP sequences, with initial capacity and ratio.
* Factory method: ``Buffers.gpAutoBuffer(Allocator allocator, int initCapacity, double ratio)``
* [Power of 2 (POW2)](https://en.wikipedia.org/wiki/Power_of_two): grows with double capacity.
* Factory method: ``Buffers.pow2AutoBuffer(Allocator allocator, int initCapacity)``

## Allocator
* [Allocator](bbutils/src/main/java/com/dopsun/bbutils/Allocator.java) allocator for ``Buffer``.
* [FixedBufferAllocator](bbutils/src/main/java/com/dopsun/bbutils/FixedBufferAllocator.java): allocator for ``FixedBufferAllocator``.
* [Allocators](bbutils/src/main/java/com/dopsun/bbutils/Allocators.java): factory methods for ``Allocator``.
* Allocator from pool: ``Allocators.fromPool(IntFunction poolFactory)``

## Pool
* [Pool](bbutils/src/main/java/com/dopsun/bbutils/Pool.java) pool for ``Buffer``.
* [FixedBufferPool](bbutils/src/main/java/com/dopsun/bbutils/FixedBufferPool.java) pool for ``FixedBufferAllocator``.
* [Pools](bbutils/src/main/java/com/dopsun/bbutils/Pools.java) factory methods for ``Pool``.
* Pool from allocator:
* ``Pools.fromAllocator(FixedBufferAllocator allocator, int bufferCapacity)``
* ``Pools.fromAllocator(FixedBufferAllocator allocator, int bufferCapacity, int initSize)``