Class MapContainer<S extends Tracked<K>,K extends WorldKey>

java.lang.Object
net.paulem.arcana.regions.container.blocks.MapContainer<S,K>
Type Parameters:
S - the type of tracked objects, which must implement the Tracked interface
K - the type of the key associated with the tracked object
All Implemented Interfaces:
SectionContainer<S,K>

public class MapContainer<S extends Tracked<K>,K extends WorldKey> extends Object implements SectionContainer<S,K>
A SectionContainer implementation backed by a sparse Int2ObjectOpenHashMap. Well-suited for sections with few occupied positions, since it only allocates entries for positions that are actually in use.
  • Constructor Details

    • MapContainer

      public MapContainer()
  • Method Details

    • get

      public Holder<S,K> get(int position)
      Retrieves the holder stored at the given position.
      Specified by:
      get in interface SectionContainer<S extends Tracked<K>,K extends WorldKey>
      Parameters:
      position - the index to look up
      Returns:
      the holder at the position, or null if empty
    • set

      public void set(int position, Holder<S,K> holder)
      Stores or clears the holder at the given position.
      Specified by:
      set in interface SectionContainer<S extends Tracked<K>,K extends WorldKey>
      Parameters:
      position - the index to store the holder at
      holder - the holder to store, or null to clear the position
    • getAll

      public it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap<Holder<S,K>> getAll()
      Specified by:
      getAll in interface SectionContainer<S extends Tracked<K>,K extends WorldKey>
      Returns:
      a shallow copy of the underlying map of position to holder
    • size

      public int size()
      Specified by:
      size in interface SectionContainer<S extends Tracked<K>,K extends WorldKey>
      Returns:
      the number of occupied positions in this container
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface SectionContainer<S extends Tracked<K>,K extends WorldKey>
      Returns:
      true if no positions are currently occupied