Class IdRegistry<T>


  • public class IdRegistry<T>
    extends Object
    Object registration system that allows looking up objects via stable IDs.

    This class may recycle deallocated IDs for new allocations.

    • Constructor Detail

      • IdRegistry

        public IdRegistry()
    • Method Detail

      • allocateId

        public int allocateId​(IntFunction<T> factory)
        Provides a new ID referencing the provided object.
        Returns:
        ID referencing the provided object
      • deallocate

        public void deallocate​(int id)
      • get

        public T get​(int id)
      • sizeOf

        public long sizeOf()
        Does not include the sizes of the referenced objects themselves.