Skip to content

dopsun/bbutils

Repository files navigation

bbutils

Build Status

java.nio.ByteBuffer related utilities.

Buffer, FixedBuffer and AutoBuffer

  • Buffer a buffer inspired from java.nio.ByteBuffer.

FixedBuffer

FixedBuffer is an abstraction similar to java.nio.ByteBuffer. Refer to FixedBuffer to find out details.

AutoBuffer

There are 3 types of auto buffer:

  • Arithmetic Progression (AP): grows following AP sequences, with initial capacity and difference.
    • Factory method: Buffers.apAutoBuffer(Allocator allocator, int initCapacity, int difference)
  • Geometric Progression (GP): grows following GP sequences, with initial capacity and ratio.
    • Factory method: Buffers.gpAutoBuffer(Allocator allocator, int initCapacity, double ratio)
  • Power of 2 (POW2): grows with double capacity.
    • Factory method: Buffers.pow2AutoBuffer(Allocator allocator, int initCapacity)

Allocator

  • Allocator allocator for Buffer.
  • Allocators: factory methods for Allocator.
    • Allocator from pool: Allocators.fromPool(IntFunction<FixedBufferPool> poolFactory)

Pool

  • Pool pool for Buffer.
  • Pools factory methods for Pool.
    • Pool from allocator:
      • Pools.fromAllocator(FixedBufferAllocator allocator, int bufferCapacity)
      • Pools.fromAllocator(FixedBufferAllocator allocator, int bufferCapacity, int initSize)