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 TypeMethodDescriptiondefault booleancontains(int id) Returns whether the id has a mapping.intgetNewId(int id) Returns the mapped id from the given id, or -1 if invalid/out of bounds.default intgetNewIdOrDefault(int id, int def) Returns the mapped id from the given id, or the given default if unmapped/invalid.inverse()Mappings with keys and values swapped.static booleanisFullIdentity(@Nullable Mappings mappings) Returns whether the mappings null or full identity mappings.default booleanReturns whether the mappings are unchanged identity mappings.static booleanisIntIdIdentity(@Nullable Mappings mappings) Returns whether the mappings null or identity mappings.intReturns the amount of new ids total, even if it does not have a direct mapping.voidsetNewId(int id, int mappedId) Manually maps a specific id.intsize()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 iddef- 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 idmappedId- 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
Returns whether the mappings null or identity mappings.- Parameters:
mappings- mappings- Returns:
- whether the mappings are identity mappings
- See Also:
-
isFullIdentity
Returns whether the mappings null or full identity mappings. Stronger thanisIntIdIdentity(Mappings), but equal to that if notFullMappings.- Parameters:
mappings- mappings- Returns:
- whether the mappings are full identity mappings
- See Also:
-