Top Description Fields Constructors Methods
com.carrotsearch.hppc

public final Class BoundedProportionalArraySizingStrategy

extends Object
implements ArraySizingStrategy
Class Inheritance
All Implemented Interfaces
com.carrotsearch.hppc.ArraySizingStrategy, com.carrotsearch.hppc.Accountable
Imports
java.util.ArrayList

Array resizing proportional to the current buffer size, optionally kept within the given minimum and maximum growth limits. Java's ArrayList uses:
minGrow = 1
maxGrow = Integer.MAX_VALUE (unbounded)
growRatio = 1.5f

Field Summary

Modifier and TypeField and Description
public static final float
DEFAULT_GROW_RATIO

Default resize is by half the current buffer's size.

public static final BoundedProportionalArraySizingStrategy
public static final int
DEFAULT_MAX_GROW_COUNT

Maximum grow count (unbounded).

public static final int
DEFAULT_MIN_GROW_COUNT

Minimum grow count.

public final float
growRatio

The current buffer length is multiplied by this ratio to get the first estimate for the new size.

public static final int
MAX_ARRAY_LENGTH

Maximum allocable array length (approximately the largest positive integer decreased by the array's object header).

public final int
maxGrowCount

Maximum number of elements to grow, if limit exceeded.

public final int
minGrowCount

Minimum number of elements to grow, if limit exceeded.

Constructor Summary

AccessConstructor and Description
public
BoundedProportionalArraySizingStrategy()

Create the default sizing strategy.

public
BoundedProportionalArraySizingStrategy(int
Minimum number of elements to grow by when expanding.
minGrow
,
int
Maximum number of elements to grow by when expanding.
maxGrow
,
float
The ratio of expansion compared to the previous buffer size.
ratio
)

Create the sizing strategy with custom policies.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

New buffer size.
grow
(int
The current length of the buffer.
currentBufferLength
,
int
The number of elements stored in the buffer.
elementsCount
,
int
The number of expected additions to the buffer.
expectedAdditions
)

Implements com.carrotsearch.hppc.ArraySizingStrategy.grow.

Grow according to growRatio, minGrowCount and maxGrowCount.

public long
public long
ramBytesUsed()

Implements com.carrotsearch.hppc.Accountable.ramBytesUsed.

Bytes that is actually been used

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_GROW_RATIOback to summary
public static final float DEFAULT_GROW_RATIO

Default resize is by half the current buffer's size.

DEFAULT_INSTANCEback to summary
public static final BoundedProportionalArraySizingStrategy DEFAULT_INSTANCE

Instance of BoundedProportionalArraySizingStrategy with default values.

DEFAULT_MAX_GROW_COUNTback to summary
public static final int DEFAULT_MAX_GROW_COUNT

Maximum grow count (unbounded).

DEFAULT_MIN_GROW_COUNTback to summary
public static final int DEFAULT_MIN_GROW_COUNT

Minimum grow count.

growRatioback to summary
public final float growRatio

The current buffer length is multiplied by this ratio to get the first estimate for the new size. To double the size of the current buffer, for example, set to 2.

MAX_ARRAY_LENGTHback to summary
public static final int MAX_ARRAY_LENGTH

Maximum allocable array length (approximately the largest positive integer decreased by the array's object header).

maxGrowCountback to summary
public final int maxGrowCount

Maximum number of elements to grow, if limit exceeded.

minGrowCountback to summary
public final int minGrowCount

Minimum number of elements to grow, if limit exceeded.

Constructor Detail

BoundedProportionalArraySizingStrategyback to summary
public BoundedProportionalArraySizingStrategy()

Create the default sizing strategy.

BoundedProportionalArraySizingStrategyback to summary
public BoundedProportionalArraySizingStrategy(int minGrow, int maxGrow, float ratio)

Create the sizing strategy with custom policies.

Parameters
minGrow:int

Minimum number of elements to grow by when expanding.

maxGrow:int

Maximum number of elements to grow by when expanding.

ratio:float

The ratio of expansion compared to the previous buffer size.

Method Detail

growback to summary
public int grow(int currentBufferLength, int elementsCount, int expectedAdditions)

Implements com.carrotsearch.hppc.ArraySizingStrategy.grow.

Grow according to growRatio, minGrowCount and maxGrowCount.

Parameters
currentBufferLength:int

The current length of the buffer.

elementsCount:int

The number of elements stored in the buffer.

expectedAdditions:int

The number of expected additions to the buffer.

Returns:int

New buffer size.

ramBytesAllocatedback to summary
public long ramBytesAllocated()

Implements com.carrotsearch.hppc.Accountable.ramBytesAllocated.

Doc from com.carrotsearch.hppc.Accountable.ramBytesAllocated.

Allocated memory estimation

Returns:long

Ram allocated in bytes

Annotations
@Override
ramBytesUsedback to summary
public long ramBytesUsed()

Implements com.carrotsearch.hppc.Accountable.ramBytesUsed.

Doc from com.carrotsearch.hppc.Accountable.ramBytesUsed.

Bytes that is actually been used

Returns:long

Ram used in bytes

Annotations
@Override