Package party.iroiro.luajava
Class LuaInstances<T>
java.lang.Object
party.iroiro.luajava.LuaInstances<T>
- Type Parameters:
T- instance type
A collection of
Jua instances, each labeled with a unique id-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected LuaInstances.Token<T>add()protected intAdds the instance to the collection and allocates a new idprotected intaddNullable(@Nullable T instance) protected @Nullable Tget(int id) Returns the instance with the specified idprotected voidremove(int id) Removes the instance from the collection, marking the id as usable againprotected intsize()Returns the number of elements in this collection
-
Constructor Details
-
LuaInstances
protected LuaInstances()
-
-
Method Details
-
add
Adds the instance to the collection and allocates a new id- Parameters:
instance- element to be added to this collection- Returns:
- the allocated id
-
addNullable
-
add
-
get
Returns the instance with the specified id- Parameters:
id- id of the instance to return- Returns:
- the element with the specified id
-
remove
protected void remove(int id) Removes the instance from the collection, marking the id as usable againThe user is responsible for
AutoCloseableresources.- Parameters:
id- the id of the instance to be removed
-
size
protected int size()Returns the number of elements in this collection- Returns:
- the number of elements in this collection
-