Class StringTable

  • All Implemented Interfaces:
    java.util.function.Function<java.lang.CharSequence,​java.lang.String>

    public final class StringTable
    extends java.lang.Object
    implements java.util.function.Function<java.lang.CharSequence,​java.lang.String>
    This is a simple, not thread-safe, caching string table that converts CharSequence to String objects.

    The implementation uses an FNV-1a hash, and collisions simply overwrite the previously cached value.

    • Constructor Summary

      Constructors 
      Constructor Description
      StringTable()
      Create a string table with 2048 entries.
      StringTable​(int sizeBits)
      Create a string table with a specific number of entries.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String apply​(java.lang.CharSequence chars)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.function.Function

        andThen, compose
    • Constructor Detail

      • StringTable

        public StringTable()
        Create a string table with 2048 entries.
      • StringTable

        public StringTable​(int sizeBits)
        Create a string table with a specific number of entries.
        Parameters:
        sizeBits - Size of the table based on bit shifting (e.g., 1 -> 2, 2 -> 4, ..., 10 -> 1024, 11 -> 2048).
    • Method Detail

      • apply

        public java.lang.String apply​(java.lang.CharSequence chars)
        Specified by:
        apply in interface java.util.function.Function<java.lang.CharSequence,​java.lang.String>