java.lang.Object
uk.ac.manchester.tornado.api.types.collections.VectorInt
- All Implemented Interfaces:
Serializable,TornadoCollectionInterface<IntBuffer>,PrimitiveStorage<IntBuffer>
VectorInt relies on preview features of the Java platform:
VectorIntrefers to one or more preview APIs:MemorySegment.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasBuffer()voidclear()static intPerform dot-product.Duplicates this vector.voidfill(int value) Sets all elements to value.intget(int index) Returns the int at the given index of this vector.getArray()intlonglongbooleanVector equality test.voidloadFromBuffer(IntBuffer buffer) static intstatic intvoidset(int[] values) Sets the elements of this vector to that of the provided array.voidset(int index, int value) Sets the int at the given index of this vector.voidSets the elements of this vector to that of the provided vector.intsize()subVector(int start, int length) Returns slice of this vector.toString()Prints the vector using the specified format string.
-
Constructor Details
-
VectorInt
Creates a vector using the provided backing array.- Parameters:
numElements- number of elementsarray- reference to the input array
-
VectorInt
public VectorInt(int numElements) Creates an empty vector with.- Parameters:
numElements- number of elements
-
VectorInt
Creates an new vector from the provided storage.- Parameters:
storage- vector int array
-
-
Method Details
-
min
-
max
-
dot
Perform dot-product.- Returns:
- int value
-
getArray
-
get
public int get(int index) Returns the int at the given index of this vector.- Parameters:
index- index value- Returns:
- int
-
set
public void set(int index, int value) Sets the int at the given index of this vector.- Parameters:
index- index valuevalue- value to be set in position index
-
set
Sets the elements of this vector to that of the provided vector.- Parameters:
values- assign an input vector int to the internal array
-
set
public void set(int[] values) Sets the elements of this vector to that of the provided array.- Parameters:
values- assign an input vector int to the internal array
-
fill
public void fill(int value) Sets all elements to value.- Parameters:
value- Fill input vector with value
-
subVector
Returns slice of this vector.- Parameters:
start- starting indexlength- number of elements- Returns:
VectorInt
-
duplicate
Duplicates this vector.- Returns:
VectorInt
-
isEqual
Vector equality test.- Parameters:
vector- Input vector to compare- Returns:
- true if vectors match
-
toString
Prints the vector using the specified format string.- Parameters:
fmt- String Format- Returns:
- String
-
toString
-
loadFromBuffer
- Specified by:
loadFromBufferin interfacePrimitiveStorage<IntBuffer>
-
asBuffer
- Specified by:
asBufferin interfacePrimitiveStorage<IntBuffer>
-
size
public int size()- Specified by:
sizein interfacePrimitiveStorage<IntBuffer>
-
getLength
public int getLength() -
clear
public void clear() -
getNumBytes
public long getNumBytes()- Specified by:
getNumBytesin interfaceTornadoCollectionInterface<IntBuffer>
-
getNumBytesWithHeader
public long getNumBytesWithHeader()- Specified by:
getNumBytesWithHeaderin interfaceTornadoCollectionInterface<IntBuffer>
-
getSegment
- Specified by:
getSegmentin interfaceTornadoCollectionInterface<IntBuffer>
-
getSegmentWithHeader
- Specified by:
getSegmentWithHeaderin interfaceTornadoCollectionInterface<IntBuffer>
-
VectorIntwhen preview features are enabled.