Package icyllis.arc3d.engine

# Class KeyBuilder

java.lang.Object
icyllis.arc3d.engine.Key
icyllis.arc3d.engine.KeyBuilder

Direct Known Subclasses:
  `PipelineKey_old`

public non-sealed class KeyBuilder extends Key
Used to build a packed array as the storage or lookup key of a hash map.

Note: A `flush()` is expected at the end of key building.

- ## Field Summary

  ### Fields inherited from class icyllis.arc3d.engine.Key

  `EMPTY`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `KeyBuilder()`
  `KeyBuilder(KeyBuilder other)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addBits(int numBits, int value, String label)`
  `final void`
  `addBool(boolean b, String label)`
  `final void`
  `addInt(int v)`
  Makes a word-boundary and adds a full word.
  `final void`
  `addInt32(int v, String label)`
  `final void`
  `addInts(int[] v, int off, int len)`
  Makes a word-boundary and adds an array of words.
  `final void`
  `clear()`
  Resets this key builder to initial state.
  `final boolean`
  `equals(Object o)`
  Compares with packed int array (storage key).
  `final void`
  `flush()`
  Introduces a word-boundary in the key.
  `final int`
  `hashCode()`
  Same as `Arrays.hashCode(int[])`.
  `final boolean`
  `isEmpty()`
  `final int`
  `size()`
  `final Key`
  `toStorageKey()`
  `final void`
  `trim()`
  Trims the backing store so that the capacity is equal to the size.

  ### Methods inherited from class icyllis.arc3d.engine.Key

  `get`

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### KeyBuilder

    public KeyBuilder()

  - ### KeyBuilder

    public KeyBuilder(@Nonnull KeyBuilder other)

- ## Method Details

  - ### clear

    public final void clear()
    Resets this key builder to initial state.

  - ### size

    public final int size()
    Overrides:
      `size` in class `Key`
    Returns:
      the number of ints

  - ### isEmpty

    public final boolean isEmpty()
    Overrides:
      `isEmpty` in class `Key`
    Returns:
      true if this key builder contains no bits

  - ### addBits

    public void addBits(int numBits, int value, String label)

  - ### addBool

    public final void addBool(boolean b, String label)

  - ### addInt32

    public final void addInt32(int v, String label)

  - ### addInt

    public final void addInt(int v)
    Makes a word-boundary and adds a full word.

  - ### addInts

    public final void addInts(int[] v, int off, int len)
    Makes a word-boundary and adds an array of words.

  - ### flush

    public final void flush()
    Introduces a word-boundary in the key. Must be called before using the key with any cache, but can also be called to create a break between generic data and backend-specific data.

  - ### trim

    public final void trim()
    Trims the backing store so that the capacity is equal to the size.

  - ### toStorageKey

    public final Key toStorageKey()
    Returns:
      a copy of packed int array as storage key

  - ### hashCode

    public final int hashCode()
    Same as `Arrays.hashCode(int[])`.
    Overrides:
      `hashCode` in class `Key`

  - ### equals

    public final boolean equals(Object o)
    Compares with packed int array (storage key).
    Overrides:
      `equals` in class `Key`