Package com.mta.tehreer.collections
Class PointList
java.lang.Object
com.mta.tehreer.collections.PointList
- All Implemented Interfaces:
Primitive
Represents a primitive list of points.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract void
copyTo
(float[] array, int atIndex) Copies all of the points in this list to an array, starting at the specified index of the target array.boolean
abstract float
getX
(int index) Returns the x- coordinate of the point at the specified index in this list.abstract float
getY
(int index) Returns the y- coordinate of the point at the specified index in this list.int
hashCode()
static PointList
of
(float... values) Returns a point list whose elements are the specified values.abstract int
size()
Returns the number of points in this list.abstract PointList
subList
(int fromIndex, int toIndex) Returns a view of the portion of this list between the specifiedfromIndex
, inclusive, andtoIndex
, exclusive.float[]
toArray()
Returns a new array containing all of the elements in this list in proper sequence (from first to last element).toString()
-
Constructor Details
-
PointList
public PointList()
-
-
Method Details
-
of
Returns a point list whose elements are the specified values. Even numbered entries will become the x- coordinates while odd numbered entries will become the y- coordinates.- Parameters:
values
- The elements of the point list.- Returns:
- A new point list.
-
size
public abstract int size()Returns the number of points in this list.- Returns:
- The number of points in this list.
-
getX
public abstract float getX(int index) Returns the x- coordinate of the point at the specified index in this list.- Parameters:
index
- Index of the point whose x- coordinate is returned.- Returns:
- The x- coordinate of the point at the specified index in this list.
- Throws:
IndexOutOfBoundsException
- if the index is out of range (index < 0 || index >= size()
).
-
getY
public abstract float getY(int index) Returns the y- coordinate of the point at the specified index in this list.- Parameters:
index
- Index of the point whose y- coordinate is returned.- Returns:
- The y- coordinate of the point at the specified index in this list.
- Throws:
IndexOutOfBoundsException
- if the index is out of range (index < 0 || index >= size()
).
-
copyTo
public abstract void copyTo(@NonNull float[] array, int atIndex) Copies all of the points in this list to an array, starting at the specified index of the target array. Each x- coordinate will be followed by y- coordinate of the point in the target array.- Parameters:
array
- The array into which the points of this list are to be copied.atIndex
- The index in the target array at which copying begins.- Throws:
NullPointerException
- ifarray
is null.IndexOutOfBoundsException
- for an illegal endpoint index value (atIndex < 0 || (array.length - atIndex) < size() * 2
).
-
subList
Returns a view of the portion of this list between the specifiedfromIndex
, inclusive, andtoIndex
, exclusive.- Parameters:
fromIndex
- Low endpoint (inclusive) of the sub list.toIndex
- High endpoint (exclusive) of the sub list.- Returns:
- A view of the specified range within this list.
- Throws:
IndexOutOfBoundsException
- for an illegal endpoint index value (fromIndex < 0 || toIndex > size() || fromIndex > toIndex
).
-
toArray
@NonNull @Size(multiple=2L) public float[] toArray()Returns a new array containing all of the elements in this list in proper sequence (from first to last element). Even numbered array entries will be the x- coordinates while odd numbered array entries will be the y- coordinates.- Returns:
- A new array containing all of the elements in this list in proper sequence.
-
equals
-
hashCode
public int hashCode() -
toString
-