Package org.ddogleg.struct
Class FastAccess<T>
java.lang.Object
org.ddogleg.struct.FastAccess<T>
- All Implemented Interfaces:
Serializable
Base class for
FastArray
and DogArray
. Provides access to the data but does not provide
methods which add or grow the internal data structure.- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static interface
static interface
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns true if an object 'a' in the array returns true for 'a.equals(o)'int
count
(FastAccess.FunctionMatches<T> test) Counts the number of times an element returns true when passed into 'test'filter
(FastAccess.FunctionMatches<T> function) Same asfindAll(java.util.List<T>, org.ddogleg.struct.FastAccess.FunctionMatches<T>)
but returns a new list.find
(FastAccess.FunctionMatches<T> function) Returns the first instance which matches the function.boolean
findAll
(List<T> matches, FastAccess.FunctionMatches<T> function) Finds the indexes of all elements which match.boolean
findAllIdx
(DogArray_I32 matches, FastAccess.FunctionMatches<T> function) Finds the indexes of all elements which match.int
findIdx
(FastAccess.FunctionMatches<T> function) Returns the first instance's index which matches the function.void
forEach
(int idx0, int idx1, FastAccess.FunctionEach<T> function) For each with a range of values specifiedvoid
forEach
(FastAccess.FunctionEach<T> function) The passed in function is called once for each element in the listvoid
forIdx
(int idx0, int idx1, FastAccess.FunctionEachIdx<T> function) For each with a range of values specifiedvoid
forIdx
(FastAccess.FunctionEachIdx<T> function) The passed in function is called once for each element in the listget
(int index) int
The maximum number of elements before the 'data' array needs to growgetTail()
getTail
(int index) Returns an element in the list relative to the tailint
Returns the first index which equals() obj.boolean
isEmpty()
True if the container has no elementsboolean
isIndexOutOfBounds
(int index) Returns true if the specified array index is outside the allowed value rangeabstract T
remove
(int index) Removes an element from the queue and preserves the order of all elements.abstract T
removeSwap
(int index) Removes the specified index from the array by swapping it with last element.void
reverse()
Reverse the item order in this queue.int
size()
Number of elements in the arrayvoid
swap
(int i, int j) Swaps the two elements in the arraytoList()
Returns a wrapper around FastQueue that allows it to act as a read only list.
-
Field Details
-
data
-
size
public int size -
type
-
-
Constructor Details
-
FastAccess
-
-
Method Details
-
get
-
isIndexOutOfBounds
public boolean isIndexOutOfBounds(int index) Returns true if the specified array index is outside the allowed value range -
getMaxSize
public int getMaxSize()The maximum number of elements before the 'data' array needs to grow- Returns:
- length of 'data'
-
remove
Removes an element from the queue and preserves the order of all elements. This is done by shifting elements in the array down one and placing the removed element at the old end of the list. O(N) runtime.- Parameters:
index
- Index of the element being removed- Returns:
- The object removed.
-
removeSwap
Removes the specified index from the array by swapping it with last element. Does not preserve order but has a runtime of O(1).- Parameters:
index
- The index to be removed.- Returns:
- The removed object
-
size
public int size()Number of elements in the array -
isEmpty
public boolean isEmpty()True if the container has no elements -
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.
-
getTail
-
getTail
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
-
contains
Returns true if an object 'a' in the array returns true for 'a.equals(o)' -
indexOf
Returns the first index which equals() obj. -1 is there is no match- Parameters:
obj
- The object being searched for- Returns:
- index or -1 if not found
-
reverse
public void reverse()Reverse the item order in this queue. -
swap
public void swap(int i, int j) Swaps the two elements in the array- Parameters:
i
- indexj
- index
-
findIdx
Returns the first instance's index which matches the function. -1 if no match is found -
find
Returns the first instance which matches the function. Null if no matches are found -
findAllIdx
Finds the indexes of all elements which match. Returns true if at least one match was found -
findAll
Finds the indexes of all elements which match. Returns true if at least one match was found -
filter
Same asfindAll(java.util.List<T>, org.ddogleg.struct.FastAccess.FunctionMatches<T>)
but returns a new list. -
forIdx
The passed in function is called once for each element in the list -
forIdx
For each with a range of values specified- Parameters:
idx0
- lower extent, inclusiveidx1
- upper extent, exclusive
-
forEach
The passed in function is called once for each element in the list -
count
Counts the number of times an element returns true when passed into 'test' -
forEach
For each with a range of values specified- Parameters:
idx0
- lower extent, inclusiveidx1
- upper extent, exclusive
-