Package org.jgroups.util
Class FastArray<T>
java.lang.Object
org.jgroups.util.FastArray<T>
- All Implemented Interfaces:
Iterable<T>
Simple
unsynchronizedarray. The array can only grow, but never shrinks (no arraycopy()). Elements are removed by nulling them. A size variable is maintained for quick size() / isEmpty().
- Since:
- 5.2
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintadd(Collection<T> list) intintintfinal intintAdds elements from an array els to this arrayintbooleanintcapacity()clear(boolean null_elements) intcount()Returns the number of non-null elements, should have the same result as size().protected static intensurePositive(int i) get(int idx) intincrement(int i) intindex()booleanisEmpty()iterator()Iterator which iterates only over non-null elements, skipping null elementsIterates over all non-null elements which match filterprint()protected Stringprint(int limit) intprintLimit(int l) remove(int idx) Replaces any or all elements matching filter with a new elementresize(int new_capacity) intsize()stream()toString()inttransferFrom(FastArray<T> other, boolean clear) Copies the messages from the other array into this one,Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
elements
-
index
protected int index -
size
protected int size -
increment
protected int increment -
print_limit
protected int print_limit
-
-
Constructor Details
-
FastArray
public FastArray(int capacity)
-
-
Method Details
-
capacity
public int capacity() -
index
public int index() -
size
public int size() -
isEmpty
public boolean isEmpty() -
increment
public int increment() -
increment
-
printLimit
public int printLimit() -
printLimit
-
add
-
add
-
add
Adds elements from an array els to this array- Parameters:
els- The other array, can have null elementslength- The number of elements to add. must be <= els.length- Returns:
- The number of elements added
-
add
-
add
-
add
-
add
-
transferFrom
Copies the messages from the other array into this one,including
null elements (usingSystem.arraycopy(Object, int, Object, int, int). This is the same as callingclear(boolean)followed byadd(FastArray, boolean), but supposedly faster.- Parameters:
other- The other arrayclear- Clears the other array after the transfer when true- Returns:
- The number of non-null elements transferred from other
-
get
-
set
-
set
-
anyMatch
-
remove
-
removeIf
-
replaceIf
Replaces any or all elements matching filter with a new element- Parameters:
filter- The filter, must ne non-null or no replacements will take placenew_el- The new element, can be nullreplace_all- When false, the method returns after the first match (if any). Otherwise, all matching elements are replaced
-
clear
-
iterator
Iterator which iterates only over non-null elements, skipping null elements -
iterator
Iterates over all non-null elements which match filter -
stream
-
count
public int count()Returns the number of non-null elements, should have the same result as size(). Only used for testing! -
toString
-
print
-
resize
-
print
-
ensurePositive
protected static int ensurePositive(int i)
-