Class ParallelArray
- java.lang.Object
-
- com.badlogic.gdx.graphics.g3d.particles.ParallelArray
-
public class ParallelArray extends java.lang.ObjectThis class represents an group of elements like an array, but the properties of the elements are stored as separate arrays. These arrays are calledParallelArray.Channeland are represented byParallelArray.ChannelDescriptor. It's not necessary to store primitive types in the channels but doing so will "exploit" data locality in the JVM, which is ensured for primitive types. UseParallelArray.FloatChannel,ParallelArray.IntChannel,ParallelArray.ObjectChannelto store the data.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classParallelArray.ChannelThis class represents a container of values for all the elements for a given propertystatic classParallelArray.ChannelDescriptorThis class describes the content of aParallelArray.Channelstatic interfaceParallelArray.ChannelInitializer<T extends ParallelArray.Channel>This interface is used to provide custom initialization of theParallelArray.ChanneldataclassParallelArray.FloatChannelclassParallelArray.IntChannelclassParallelArray.ObjectChannel<T>
-
Constructor Summary
Constructors Constructor Description ParallelArray(int capacity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends ParallelArray.Channel>
TaddChannel(ParallelArray.ChannelDescriptor channelDescriptor)Adds and returns a channel described by the channel descriptor parameter.<T extends ParallelArray.Channel>
TaddChannel(ParallelArray.ChannelDescriptor channelDescriptor, ParallelArray.ChannelInitializer<T> initializer)Adds and returns a channel described by the channel descriptor parameter.voidaddElement(java.lang.Object... values)Adds an element considering the values in the same order as the current channels in the array.voidclear()Removes all the channels and sets size to 0<T extends ParallelArray.Channel>
TgetChannel(ParallelArray.ChannelDescriptor descriptor)<T> voidremoveArray(int id)Removes the channel with the given idvoidremoveElement(int index)Removes the element at the given index and swaps it with the last available elementvoidsetCapacity(int requiredCapacity)Sets the capacity.
-
-
-
Method Detail
-
addChannel
public <T extends ParallelArray.Channel> T addChannel(ParallelArray.ChannelDescriptor channelDescriptor)
Adds and returns a channel described by the channel descriptor parameter. If a channel with the same id already exists, no allocation is performed and that channel is returned.
-
addChannel
public <T extends ParallelArray.Channel> T addChannel(ParallelArray.ChannelDescriptor channelDescriptor, ParallelArray.ChannelInitializer<T> initializer)
Adds and returns a channel described by the channel descriptor parameter. If a channel with the same id already exists, no allocation is performed and that channel is returned. Otherwise a new channel is allocated and initialized with the initializer.
-
removeArray
public <T> void removeArray(int id)
Removes the channel with the given id
-
addElement
public void addElement(java.lang.Object... values)
Adds an element considering the values in the same order as the current channels in the array. The n_th value must have the same type and stride of the given channel at position n
-
removeElement
public void removeElement(int index)
Removes the element at the given index and swaps it with the last available element
-
getChannel
public <T extends ParallelArray.Channel> T getChannel(ParallelArray.ChannelDescriptor descriptor)
- Returns:
- the channel with the same id as the one in the descriptor
-
clear
public void clear()
Removes all the channels and sets size to 0
-
setCapacity
public void setCapacity(int requiredCapacity)
Sets the capacity. Each contained channel will be resized to match the required capacity and the current data will be preserved.
-
-