WeightedMap

public class WeightedMap

Class WeightedMap. Provides weightedmap functionality for the Hytale server.

java.lang.Object > WeightedMap

Field Summary

array

final K[] array

Field array.

keys

private T[] keys

Field keys.

values

private double[] values

Field values.

size

private int size

Field size.

minCapacity

final int minCapacity

Field minCapacity.

allocated

final int allocated

Field allocated.

newLength

final int newLength

Field newLength.

Method Detail

builder

static Builder builder (final T[] emptyKeys)

Method builder.

Parameters:
final T[] emptyKeys

WeightedMap

public private WeightedMap (@Nonnull final T[] keys, final double[] values, final double sum)

Method WeightedMap.

Parameters:
@Nonnull final T[] keys
final double[] values
final double sum

get

public T get (final double value)

Method get.

Parameters:
final double value

size

public int size ()

Method size.

contains

public boolean contains (final T obj)

Method contains.

Parameters:
final T obj

forEach

public void forEach (@Nonnull final Consumer consumer)

Method forEach.

Parameters:
@Nonnull final Consumer consumer

forEachEntry

public void forEachEntry (@Nonnull final ObjDoubleConsumer consumer)

Method forEachEntry.

Parameters:
@Nonnull final ObjDoubleConsumer consumer

internalKeys

public T[] internalKeys ()

Method internalKeys.

toArray

public T[] toArray ()

Method toArray.

resolveKeys

public IWeightedMap resolveKeys (@Nonnull final Function mapper, @Nonnull final IntFunction arraySupplier)

Method resolveKeys.

Parameters:
@Nonnull final Function mapper
@Nonnull final IntFunction arraySupplier

toString

public String toString ()

Method toString.

SingletonWeightedMap

public private SingletonWeightedMap (@Nonnull final T[] keys)

Method SingletonWeightedMap.

Parameters:
@Nonnull final T[] keys

Builder

public private Builder (final T[] emptyKeys)

Method Builder.

Parameters:
final T[] emptyKeys

putAll

Method putAll.

Parameters:
@Nullable final IWeightedMap map

put

public Builder put (final T obj, final double weight)

Method put.

Parameters:
final T obj
final double weight

ensureCapacity

public void ensureCapacity (final int toAdd)

Method ensureCapacity.

Parameters:
final int toAdd

resize

private void resize (final int newLength)

Method resize.

Parameters:
final int newLength

insert

private void insert (final T key, final double value)

Method insert.

Parameters:
final T key
final double value

allocated

private int allocated ()

Method allocated.

clear

public void clear ()

Method clear.

build

public IWeightedMap build ()

Method build.