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.
- Host: GitHub
- URL: https://github.com/dopsun/bbutils
- Owner: dopsun
- License: apache-2.0
- Created: 2017-01-11T13:49:26.000Z (over 9 years ago)
- Default Branch: develop
- Last Pushed: 2017-03-15T13:06:16.000Z (over 9 years ago)
- Last Synced: 2025-07-22T11:56:56.920Z (11 months ago)
- Language: Java
- Size: 66.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# bbutils
[](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)``