Package org.apache.ignite.internal.util
Class GridIntList
- java.lang.Object
-
- org.apache.ignite.internal.util.GridIntList
-
- All Implemented Interfaces:
Externalizable,Serializable,Message
public class GridIntList extends Object implements Message, Externalizable
Minimal list API to work with primitive ints. This list exists to avoid boxing/unboxing when using standard list from Java.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface org.apache.ignite.plugin.extensions.communication.Message
DIRECT_TYPE_SIZE
-
-
Constructor Summary
Constructors Constructor Description GridIntList()GridIntList(int size)GridIntList(int[] arr)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int x)Add element to this array.int[]array()static GridIntListasList(int... vals)booleancontains(int l)GridIntListcopyWithout(GridIntList l)Returns (possibly reordered) copy of this list, excluding all elements of given list.shortdirectType()Gets message type.booleanequals(Object o)bytefieldsCount()Gets fields count.intget(int i)inthashCode()booleanisEmpty()GridIntIteratoriterator()voidonAckReceived()Method called when ack message received.voidreadExternal(ObjectInput in)booleanreadFrom(ByteBuffer buf, MessageReader reader)Reads this message from provided byte buffer.intremoveIndex(int i)Removes element by given index.intremoveValue(int startIdx, int val)Removes value from this list.intsize()GridIntListsort()Sorts this list.StringtoString()voidtruncate(int size, boolean last)voidwriteExternal(ObjectOutput out)booleanwriteTo(ByteBuffer buf, MessageWriter writer)Writes this message to provided byte buffer.
-
-
-
Method Detail
-
asList
public static GridIntList asList(int... vals)
- Parameters:
vals- Values.- Returns:
- List from values.
-
add
public void add(int x)
Add element to this array.- Parameters:
x- Value.
-
copyWithout
public GridIntList copyWithout(GridIntList l)
Returns (possibly reordered) copy of this list, excluding all elements of given list.- Parameters:
l- List of elements to remove.- Returns:
- New list without all elements from
l.
-
get
public int get(int i)
- Parameters:
i- Index.- Returns:
- Value.
-
size
public int size()
- Returns:
- Size.
-
isEmpty
public boolean isEmpty()
- Returns:
Trueif this list has no elements.
-
contains
public boolean contains(int l)
- Parameters:
l- Element to find.- Returns:
Trueif found.
-
truncate
public void truncate(int size, boolean last)- Parameters:
size- New size.last- Iftruethe last elements will be removed, otherwise the first.
-
removeIndex
public int removeIndex(int i)
Removes element by given index.- Parameters:
i- Index.- Returns:
- Removed value.
-
removeValue
public int removeValue(int startIdx, int val)Removes value from this list.- Parameters:
startIdx- Index to begin search with.val- Value.- Returns:
- Index of removed value if the value was found and removed or
-1otherwise.
-
array
public int[] array()
- Returns:
- Array copy.
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
public void readExternal(ObjectInput in) throws IOException
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOException
-
sort
public GridIntList sort()
Sorts this list. Usecopy().sort()if you need a defensive copy.- Returns:
thisFor chaining.
-
onAckReceived
public void onAckReceived()
Method called when ack message received.- Specified by:
onAckReceivedin interfaceMessage
-
writeTo
public boolean writeTo(ByteBuffer buf, MessageWriter writer)
Writes this message to provided byte buffer.
-
readFrom
public boolean readFrom(ByteBuffer buf, MessageReader reader)
Reads this message from provided byte buffer.
-
directType
public short directType()
Gets message type.- Specified by:
directTypein interfaceMessage- Returns:
- Message type.
-
fieldsCount
public byte fieldsCount()
Gets fields count.- Specified by:
fieldsCountin interfaceMessage- Returns:
- Fields count.
-
iterator
public GridIntIterator iterator()
- Returns:
- Iterator.
-
-