Interface Mappings

All Known Subinterfaces:
BiMappings, FullMappings
All Known Implementing Classes:
BiMappingsBase, FullIdentityMappings, FullMappingsBase, IdentityMappings, Int2IntMapBiMappings, Int2IntMapMappings, IntArrayMappings, ParticleMappings

public interface Mappings
  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    contains(int id)
    Returns whether the id has a mapping.
    int
    getNewId(int id)
    Returns the mapped id from the given id, or -1 if invalid/out of bounds.
    default int
    getNewIdOrDefault(int id, int def)
    Returns the mapped id from the given id, or the given default if unmapped/invalid.
    Mappings with keys and values swapped.
    static boolean
    isFullIdentity(@Nullable Mappings mappings)
    Returns whether the mappings null or full identity mappings.
    default boolean
    Returns whether the mappings are unchanged identity mappings.
    static boolean
    isIntIdIdentity(@Nullable Mappings mappings)
    Returns whether the mappings null or identity mappings.
    int
    Returns the amount of new ids total, even if it does not have a direct mapping.
    void
    setNewId(int id, int mappedId)
    Manually maps a specific id.
    int
    Returns amount of unmapped entries, being the size of the mapping.
  • Method Details

    • getNewId

      int getNewId(int id)
      Returns the mapped id from the given id, or -1 if invalid/out of bounds.
      Parameters:
      id - unmapped id
      Returns:
      mapped id, or -1 if invalid/out of bounds
    • getNewIdOrDefault

      default int getNewIdOrDefault(int id, int def)
      Returns the mapped id from the given id, or the given default if unmapped/invalid.
      Parameters:
      id - unmapped id
      def - fallback return value
      Returns:
      mapped id, or def if invalid/out of bounds
    • contains

      default boolean contains(int id)
      Returns whether the id has a mapping.
      Parameters:
      id - unmapped id
      Returns:
      whether the id has a mapped id
    • setNewId

      void setNewId(int id, int mappedId)
      Manually maps a specific id.
      Parameters:
      id - unmapped id
      mappedId - mapped id
      Throws:
      IndexOutOfBoundsException - if the unmapped id is invalid
    • size

      int size()
      Returns amount of unmapped entries, being the size of the mapping.
      Returns:
      amount of unmapped entries
    • mappedSize

      int mappedSize()
      Returns the amount of new ids total, even if it does not have a direct mapping. Returns -1 if unknown.
      Returns:
      amount of new ids, or -1 if unknown
    • inverse

      Mappings inverse()
      Mappings with keys and values swapped.
      Returns:
      mappings with keys and values swapped
    • isIdentity

      default boolean isIdentity()
      Returns whether the mappings are unchanged identity mappings.
      Returns:
      whether the mappings are unchanged identity mappings
    • isIntIdIdentity

      static boolean isIntIdIdentity(@Nullable Mappings mappings)
      Returns whether the mappings null or identity mappings.
      Parameters:
      mappings - mappings
      Returns:
      whether the mappings are identity mappings
      See Also:
    • isFullIdentity

      static boolean isFullIdentity(@Nullable Mappings mappings)
      Returns whether the mappings null or full identity mappings. Stronger than isIntIdIdentity(Mappings), but equal to that if not FullMappings.
      Parameters:
      mappings - mappings
      Returns:
      whether the mappings are full identity mappings
      See Also: