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.

  • 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()
      Overrides:
      hashCode in class Key
    • equals

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