org.ddogleg.struct
Class FastQueue<T>
- java.lang.Object
-
- org.ddogleg.struct.FastQueue<T>
-
- All Implemented Interfaces:
- java.io.Serializable
- Direct Known Subclasses:
- BriefFeatureQueue, ColorQueue_F32, FastQueueArray_F64, FastQueueArray_I32, NccFeatureQueue, QueueCorner, QueueMatrix, SurfFeatureQueue
public class FastQueue<T> extends java.lang.Object implements java.io.SerializableGrowable array designed for fast access. It can be configured to declare new instances or just grow the array.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field and Description T[]dataintsizejava.lang.Class<T>type
-
Constructor Summary
Constructors Constructor and Description FastQueue(java.lang.Class<T> type, boolean declareInstances)FastQueue(int initialMaxSize, java.lang.Class<T> type, boolean declareInstances)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidadd(T object)voidaddAll(FastQueue<T> list)booleancontains(java.lang.Object o)java.util.List<T>copyIntoList(java.util.List<T> ret)Tget(int index)Returns the element at the specified index.T[]getData()intgetMaxSize()intgetSize()TgetTail()TgetTail(int index)Returns an element in the list relative to the tailjava.lang.Class<T>getType()Tgrow()Returns a new element of data.voidgrowArray(int length)Increases the size of the internal array without changing the shape's size.booleanisDeclareInstances()voidremove(int index)Removes an element from the queue by shifting elements in the array down one and placing the removed element at the old end of the list.TremoveTail()Shrinks the size of the array by one and returns the element stored at the former last element.voidreset()voidresize(int length)Changes the size to the specified length.voidreverse()Reverse the item order in this queue.voidsetData(T[] data)voidsetDeclareInstances(boolean declareInstances)voidsetSize(int size)voidsetType(java.lang.Class<T> type)intsize()java.util.List<T>toList()Returns a wrapper around FastQueue that allows it to act as a read only list.
-
-
-
Constructor Detail
-
FastQueue
public FastQueue(int initialMaxSize, java.lang.Class<T> type, boolean declareInstances)
-
FastQueue
public FastQueue(java.lang.Class<T> type, boolean declareInstances)
-
-
Method Detail
-
toList
public java.util.List<T> toList()
Returns a wrapper around FastQueue that allows it to act as a read only list. There is little overhead in using this interface. NOTE: The same instead of a list is returned each time. Be careful when writing concurrent code and create a copy.- Returns:
- List wrapper.
-
removeTail
public T removeTail()
Shrinks the size of the array by one and returns the element stored at the former last element.- Returns:
- The last element in the list that was removed.
-
getTail
public T getTail()
-
getTail
public T getTail(int index)
Returns an element in the list relative to the tail- Parameters:
index- index relative to tail. 0 == the tail. size-1 = first element- Returns:
- element
-
reset
public void reset()
-
getMaxSize
public int getMaxSize()
-
size
public int size()
-
reverse
public void reverse()
Reverse the item order in this queue.
-
get
public T get(int index)
Returns the element at the specified index. Bounds checking is performed.- Parameters:
index- Index of the element being retrieved- Returns:
- The retrieved element
-
grow
public T grow()
Returns a new element of data. If there are new data elements available then array will automatically grow.- Returns:
- A new instance.
-
remove
public void remove(int index)
Removes an element from the queue by shifting elements in the array down one and placing the removed element at the old end of the list.- Parameters:
index- Index of the element being removed
-
add
public void add(T object)
-
growArray
public void growArray(int length)
Increases the size of the internal array without changing the shape's size. If the array is already larger than the specified length then nothing is done. Elements previously stored in the array are copied over is a new internal array is declared.- Parameters:
length- Requested size of internal array.
-
resize
public void resize(int length)
Changes the size to the specified length. Equivalent to callinggrowArray(int)and this.size = N.- Parameters:
length- The new size of the queue
-
contains
public boolean contains(java.lang.Object o)
-
getData
public T[] getData()
-
setData
public void setData(T[] data)
-
getSize
public int getSize()
-
setSize
public void setSize(int size)
-
isDeclareInstances
public boolean isDeclareInstances()
-
setDeclareInstances
public void setDeclareInstances(boolean declareInstances)
-
getType
public java.lang.Class<T> getType()
-
setType
public void setType(java.lang.Class<T> type)
-
-
DataMelt 3.0 © DataMelt by jWork.ORG