org.geotools.resources
Class XArray

java.lang.Object
  extended byorg.geotools.resources.XArray

public final class XArray
extends java.lang.Object

Simple operations on arrays. This class provides a central place for inserting and deleting elements in an array, as well as resizing the array. This class may be removed if JavaSoft provide some language construct functionally equivalent to C/C++'s .

Since:
2.0
Version:
$Id: XArray.java 17672 2006-01-19 00:25:55Z desruisseaux $
Author:
Martin Desruisseaux

Method Summary
static boolean hasNaN(double[] array)
          Returns if the specified array contains at least one NaN value.
static boolean hasNaN(float[] array)
          Returns if the specified array contains at least one NaN value.
static boolean[] insert(boolean[] src, int src_pos, boolean[] dst, int dst_pos, int length)
          Inserts a table slice into another table.
static boolean[] insert(boolean[] array, int index, int length)
          Inserts spaces into the middle of a table.
static byte[] insert(byte[] src, int src_pos, byte[] dst, int dst_pos, int length)
          Inserts a table slice into another table.
static byte[] insert(byte[] array, int index, int length)
          Inserts spaces into the middle of a table.
static char[] insert(char[] src, int src_pos, char[] dst, int dst_pos, int length)
          Inserts a table slice into another table.
static char[] insert(char[] array, int index, int length)
          Inserts spaces into the middle of a table.
static double[] insert(double[] src, int src_pos, double[] dst, int dst_pos, int length)
          Inserts a table slice into another table.
static double[] insert(double[] array, int index, int length)
          Inserts spaces into the middle of a table.
static float[] insert(float[] src, int src_pos, float[] dst, int dst_pos, int length)
          Inserts a table slice into another table.
static float[] insert(float[] array, int index, int length)
          Inserts spaces into the middle of a table.
static int[] insert(int[] array, int index, int length)
          Inserts spaces into the middle of a table.
static int[] insert(int[] src, int src_pos, int[] dst, int dst_pos, int length)
          Inserts a table slice into another table.
static long[] insert(long[] array, int index, int length)
          Inserts spaces into the middle of a table.
static long[] insert(long[] src, int src_pos, long[] dst, int dst_pos, int length)
          Inserts a table slice into another table.
static java.lang.Object[] insert(java.lang.Object[] array, int index, int length)
          Inserts spaces into the middle of a table.
static java.lang.Object[] insert(java.lang.Object[] src, int src_pos, java.lang.Object[] dst, int dst_pos, int length)
          Inserts a table slice into another table.
static short[] insert(short[] array, int index, int length)
          Inserts spaces into the middle of a table.
static short[] insert(short[] src, int src_pos, short[] dst, int dst_pos, int length)
          Inserts a table slice into another table.
static boolean isSorted(byte[] array)
          Returns if all elements in the specified array are in increasing order.
static boolean isSorted(char[] array)
          Returns if all elements in the specified array are in increasing order.
static boolean isSorted(double[] array)
          Returns if all elements in the specified array are in increasing order.
static boolean isSorted(float[] array)
          Returns if all elements in the specified array are in increasing order.
static boolean isSorted(int[] array)
          Returns if all elements in the specified array are in increasing order.
static boolean isSorted(long[] array)
          Returns if all elements in the specified array are in increasing order.
static boolean isSorted(short[] array)
          Returns if all elements in the specified array are in increasing order.
static boolean isStrictlySorted(int[] array)
          Returns if all elements in the specified array are in strictly increasing order.
static boolean[] remove(boolean[] array, int index, int length)
          Grabs elements from the middle of a table.
static byte[] remove(byte[] array, int index, int length)
          Grabs elements from the middle of a table.
static char[] remove(char[] array, int index, int length)
          Grabs elements from the middle of a table.
static double[] remove(double[] array, int index, int length)
          Grabs elements from the middle of a table.
static float[] remove(float[] array, int index, int length)
          Grabs elements from the middle of a table.
static int[] remove(int[] array, int index, int length)
          Grabs elements from the middle of a table.
static long[] remove(long[] array, int index, int length)
          Grabs elements from the middle of a table.
static java.lang.Object[] remove(java.lang.Object[] array, int index, int length)
          Grabs elements from the middle of a table.
static short[] remove(short[] array, int index, int length)
          Grabs elements from the middle of a table.
static boolean[] resize(boolean[] array, int length)
          Returns a new table which contains the same elements as but with the specified.
static byte[] resize(byte[] array, int length)
          Returns a new table which contains the same elements as but with the specified.
static char[] resize(char[] array, int length)
          Returns a new table which contains the same elements as but with the specified.
static double[] resize(double[] array, int length)
          Returns a new table which contains the same elements as but with the specified.
static float[] resize(float[] array, int length)
          Returns a new table which contains the same elements as but with the specified.
static int[] resize(int[] array, int length)
          Returns a new table which contains the same elements as but with the specified.
static long[] resize(long[] array, int length)
          Returns a new table which contains the same elements as but with the specified.
static java.lang.Object[] resize(java.lang.Object[] array, int length)
          Returns a new table which contains the same elements as but with the specified.
static short[] resize(short[] array, int length)
          Returns a new table which contains the same elements as but with the specified.
static java.lang.String toString(java.lang.Object array, java.util.Locale locale)
          Returns a string representation of an array of numbers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

resize

public static java.lang.Object[] resize(java.lang.Object[] array,
                                        int length)
Returns a new table which contains the same elements as but with the specified. If the desired is longer than the initial length of the table, the returned table will contain all the elements of as well as the elements initialised to at the end of the table. If, on the contrary, the desired is shorter than the initial length of the table, the table will be truncated (that is to say the surplus elements will be forgotten). If the length of is equal to , then will be returned as it stands.

Parameters:
array - Table to copy.
length - Length of the desired table.
Returns:
Table of the same type as , of length and containing the data from .

resize

public static double[] resize(double[] array,
                              int length)
Returns a new table which contains the same elements as but with the specified. If the desired is longer than the initial length of the table, the returned table will contain all the elements of as well as the elements initialised to at the end of the table. If, on the contrary, the desired is shorter than the initial length of the table, the table will be truncated (that is to say the surplus elements will be forgotten). If the length of is equal to , then will be returned as it stands.

Parameters:
array - Table to copy.
length - Length of the desired table.
Returns:
Table of the same type as , of length and containing the data from .

resize

public static float[] resize(float[] array,
                             int length)
Returns a new table which contains the same elements as but with the specified. If the desired is longer than the initial length of the table, the returned table will contain all the elements of as well as the elements initialised to at the end of the table. If, on the contrary, the desired is shorter than the initial length of the table, the table will be truncated (that is to say the surplus elements will be forgotten). If the length of is equal to , then will be returned as it stands.

Parameters:
array - Table to copy.
length - Length of the desired table.
Returns:
Table of the same type as , of length and containing the data from .

resize

public static long[] resize(long[] array,
                            int length)
Returns a new table which contains the same elements as but with the specified. If the desired is longer than the initial length of the table, the returned table will contain all the elements of as well as the elements initialised to at the end of the table. If, on the contrary, the desired is shorter than the initial length of the table, the table will be truncated (that is to say the surplus elements will be forgotten). If the length of is equal to , then will be returned as it stands.

Parameters:
array - Table to copy.
length - Length of the desired table.
Returns:
Table of the same type as , of length and containing the data from .

resize

public static int[] resize(int[] array,
                           int length)
Returns a new table which contains the same elements as but with the specified. If the desired is longer than the initial length of the table, the returned table will contain all the elements of as well as the elements initialised to at the end of the table. If, on the contrary, the desired is shorter than the initial length of the table, the table will be truncated (that is to say the surplus elements will be forgotten). If the length of is equal to , then will be returned as it stands.

Parameters:
array - Table to copy.
length - Length of the desired table.
Returns:
Table of the same type as , of length and containing the data from .

resize

public static short[] resize(short[] array,
                             int length)
Returns a new table which contains the same elements as but with the specified. If the desired is longer than the initial length of the table, the returned table will contain all the elements of as well as the elements initialised to at the end of the table. If, on the contrary, the desired is shorter than the initial length of the table, the table will be truncated (that is to say the surplus elements will be forgotten). If the length of is equal to , then will be returned as it stands.

Parameters:
array - Table to copy.
length - Length of the desired table.
Returns:
Table of the same type as , of length and containing the data from .

resize

public static byte[] resize(byte[] array,
                            int length)
Returns a new table which contains the same elements as but with the specified. If the desired is longer than the initial length of the table, the returned table will contain all the elements of as well as the elements initialised to at the end of the table. If, on the contrary, the desired is shorter than the initial length of the table, the table will be truncated (that is to say the surplus elements will be forgotten). If the length of is equal to , then will be returned as it stands.

Parameters:
array - Table to copy.
length - Length of the desired table.
Returns:
Table of the same type as , of length and containing the data from .

resize

public static char[] resize(char[] array,
                            int length)
Returns a new table which contains the same elements as but with the specified. If the desired is longer than the initial length of the table, the returned table will contain all the elements of as well as the elements initialised to at the end of the table. If, on the contrary, the desired is shorter than the initial length of the table, the table will be truncated (that is to say the surplus elements will be forgotten). If the length of is equal to , then will be returned as it stands.

Parameters:
array - Table to copy.
length - Length of the desired table.
Returns:
Table of the same type as , of length and containing the data from .

resize

public static boolean[] resize(boolean[] array,
                               int length)
Returns a new table which contains the same elements as but with the specified. If the desired is longer than the initial length of the table, the returned table will contain all the elements of as well as the elements initialised to at the end of the table. If, on the contrary, the desired is shorter than the initial length of the table, the table will be truncated (that is to say the surplus elements will be forgotten). If the length of is equal to , then will be returned as it stands.

Parameters:
array - Table to copy.
length - Length of the desired table.
Returns:
Table of the same type as , of length and containing the data from .

remove

public static java.lang.Object[] remove(java.lang.Object[] array,
                                        int index,
                                        int length)
Grabs elements from the middle of a table.

Parameters:
array - Table from which to grab the elements.
index - index of the first element to grab. All subsequent elements can be moved forward.
length - Number of elements to grab.
Returns:
Table which contains the data with the extracted elements. This method can directly return , but most often it returns a newly created table.

remove

public static double[] remove(double[] array,
                              int index,
                              int length)
Grabs elements from the middle of a table.

Parameters:
array - Table from which to grab elements.
index - index of the first element to grab. All subsequent elements of can be moved forward.
length - Number of elements to grab.
Returns:
Table which contains the data with the extracted elements. This method can directly return , but most often it returns a newly created table.

remove

public static float[] remove(float[] array,
                             int index,
                             int length)
Grabs elements from the middle of a table.

Parameters:
array - Table from which to grab elements.
index - index of the first element to grab. All subsequent elements of can be moved forward.
length - Number of elements to grab.
Returns:
Table which contains the data with the extracted elements. This method can directly return , but most often it returns a newly created table.

remove

public static long[] remove(long[] array,
                            int index,
                            int length)
Grabs elements from the middle of a table.

Parameters:
array - Table from which to grab elements.
index - index of the first element to grab. All subsequent elements of can be moved forward.
length - Number of elements to grab.
Returns:
Table which contains the data with the extracted elements. This method can directly return , but most often it returns a newly created table.

remove

public static int[] remove(int[] array,
                           int index,
                           int length)
Grabs elements from the middle of a table.

Parameters:
array - Table from which to grab elements.
index - index of the first element to grab. All subsequent elements of can be moved forward.
length - Number of elements to grab.
Returns:
Table which contains the data with the extracted elements. This method can directly return , but most often it returns a newly created table.

remove

public static short[] remove(short[] array,
                             int index,
                             int length)
Grabs elements from the middle of a table.

Parameters:
array - Table from which to grab elements.
index - index of the first element to grab. All subsequent elements of can be moved forward.
length - Number of elements to grab.
Returns:
Table which contains the data with the extracted elements. This method can directly return , but most often it returns a newly created table.

remove

public static byte[] remove(byte[] array,
                            int index,
                            int length)
Grabs elements from the middle of a table.

Parameters:
array - Table from which to grab elements.
index - index of the first element to grab. All subsequent elements of can be moved forward.
length - Number of elements to grab.
Returns:
Table which contains the data with the extracted elements. This method can directly return , but most often it returns a newly created table.

remove

public static char[] remove(char[] array,
                            int index,
                            int length)
Grabs elements from the middle of a table.

Parameters:
array - Table from which to grab elements.
index - index of the first element to grab. All subsequent elements of can be moved forward.
length - Number of elements to grab.
Returns:
Table which contains the data with the extracted elements. This method can directly return , but most often it returns a newly created table.

remove

public static boolean[] remove(boolean[] array,
                               int index,
                               int length)
Grabs elements from the middle of a table.

Parameters:
array - Table from which to grab elements.
index - index of the first element to grab. All subsequent elements of can be moved forward.
length - Number of elements to grab.
Returns:
Table which contains the data with the extracted elements. This method can directly return , but most often it returns a newly created table.

insert

public static java.lang.Object[] insert(java.lang.Object[] array,
                                        int index,
                                        int length)
Inserts spaces into the middle of a table. These "spaces" will be made up of null elements.

Parameters:
array - Table in which to insert spaces.
index - index where spaces should be inserted. All elements which have an index equal to or higher than will be moved forward.
length - Number of spaces to insert.
Returns:
Table which contains the data with the additional space. This method can directly return , but most often it returns a newly created table.

insert

public static double[] insert(double[] array,
                              int index,
                              int length)
Inserts spaces into the middle of a table. These "spaces" will be made up of zeros.

Parameters:
array - Table in which to insert spaces.
index - index where spaces should be inserted. All elements which have an index equal to or higher than will be moved forward.
length - Number of spaces to insert.
Returns:
Table which contains the data with the additional space. This method can directly return , but most often it returns a newly created table.

insert

public static float[] insert(float[] array,
                             int index,
                             int length)
Inserts spaces into the middle of a table. These "spaces" will be made up of zeros.

Parameters:
array - Table in which to insert spaces.
index - index where spaces should be inserted. All elements which have an index equal to or higher than will be moved forward.
length - Number of spaces to insert.
Returns:
Table which contains the data with the additional space. This method can directly return , but most often it returns a newly created table.

insert

public static long[] insert(long[] array,
                            int index,
                            int length)
Inserts spaces into the middle of a table. These "spaces" will be made up of zeros.

Parameters:
array - Table in which to insert spaces.
index - index where spaces should be inserted. All elements which have an index equal to or higher than will be moved forward.
length - Number of spaces to insert.
Returns:
Table which contains the data with the additional space. This method can directly return , but most often it returns a newly created table.

insert

public static int[] insert(int[] array,
                           int index,
                           int length)
Inserts spaces into the middle of a table. These "spaces" will be made up of zeros.

Parameters:
array - Table in which to insert spaces.
index - index where spaces should be inserted. All elements which have an index equal to or higher than will be moved forward.
length - Number of spaces to insert.
Returns:
Table which contains the data with the additional space. This method can directly return , but most often it returns a newly created table.

insert

public static short[] insert(short[] array,
                             int index,
                             int length)
Inserts spaces into the middle of a table. These "spaces" will be made up of zeros.

Parameters:
array - Table in which to insert spaces.
index - index where spaces should be inserted. All elements which have an index equal to or higher than will be moved forward.
length - Number of spaces to insert.
Returns:
Table which contains the data with the additional space. This method can directly return , but most often it returns a newly created table.

insert

public static byte[] insert(byte[] array,
                            int index,
                            int length)
Inserts spaces into the middle of a table. These "spaces" will be made up of zeros.

Parameters:
array - Table in which to insert spaces.
index - index where spaces should be inserted. All elements which have an index equal to or higher than will be moved forward.
length - Number of spaces to insert.
Returns:
Table which contains the data with the additional space. This method can directly return , but most often it returns a newly created table.

insert

public static char[] insert(char[] array,
                            int index,
                            int length)
Inserts spaces into the middle of a table. These "spaces" will be made up of zeros.

Parameters:
array - Table in which to insert spaces.
index - index where spaces should be inserted. All elements which have an index equal to or higher than will be moved forward.
length - Number of spaces to insert.
Returns:
Table which contains the data with the additional space. This method can directly return , but most often it returns a newly created table.

insert

public static boolean[] insert(boolean[] array,
                               int index,
                               int length)
Inserts spaces into the middle of a table. These "spaces" will be made up of .

Parameters:
array - Table in which to insert spaces.
index - index where spaces should be inserted. All elements which have an index equal to or higher than will be moved forward.
length - Number of spaces to insert.
Returns:
Table which contains the data with the additional space. This method can directly return , but most often it returns a newly created table.

insert

public static java.lang.Object[] insert(java.lang.Object[] src,
                                        int src_pos,
                                        java.lang.Object[] dst,
                                        int dst_pos,
                                        int length)
Inserts a table slice into another table. The table will be entirely or partially inserted into the table.

Parameters:
src - Tablea to insert into .
src_pos - Index of the first data item of to insert into .
dst - Table in which to insert data.
dst_pos - index in which to insert data. All elements of whose index is equal to or greater than will be moved forward.
length - Number of data items to insert.
Returns:
Table which contains the combination of and . This method can directly return , but never . It most often returns a newly created table.

insert

public static double[] insert(double[] src,
                              int src_pos,
                              double[] dst,
                              int dst_pos,
                              int length)
Inserts a table slice into another table. The table will be entirely or partially inserted into the table.

Parameters:
src - Tablea to insert into .
src_pos - Index of the first data item of to insert into .
dst - Table in which to insert data.
dst_pos - index in which to insert data. All elements of whose index is equal to or greater than will be moved forward.
length - Number of data items to insert.
Returns:
Table which contains the combination of and . This method can directly return , but never . It most often returns a newly created table.

insert

public static float[] insert(float[] src,
                             int src_pos,
                             float[] dst,
                             int dst_pos,
                             int length)
Inserts a table slice into another table. The table will be entirely or partially inserted into the table.

Parameters:
src - Tablea to insert into .
src_pos - Index of the first data item of to insert into .
dst - Table in which to insert data.
dst_pos - index in which to insert data. All elements of whose index is equal to or greater than will be moved forward.
length - Number of data items to insert.
Returns:
Table which contains the combination of and . This method can directly return , but never . It most often returns a newly created table.

insert

public static long[] insert(long[] src,
                            int src_pos,
                            long[] dst,
                            int dst_pos,
                            int length)
Inserts a table slice into another table. The table will be entirely or partially inserted into the table.

Parameters:
src - Tablea to insert into .
src_pos - Index of the first data item of to insert into .
dst - Table in which to insert data.
dst_pos - index in which to insert data. All elements of whose index is equal to or greater than will be moved forward.
length - Number of data items to insert.
Returns:
Table which contains the combination of and . This method can directly return , but never . It most often returns a newly created table.

insert

public static int[] insert(int[] src,
                           int src_pos,
                           int[] dst,
                           int dst_pos,
                           int length)
Inserts a table slice into another table. The table will be entirely or partially inserted into the table.

Parameters:
src - Tablea to insert into .
src_pos - Index of the first data item of to insert into .
dst - Table in which to insert data.
dst_pos - index in which to insert data. All elements of whose index is equal to or greater than will be moved forward.
length - Number of data items to insert.
Returns:
Table which contains the combination of and . This method can directly return , but never . It most often returns a newly created table.

insert

public static short[] insert(short[] src,
                             int src_pos,
                             short[] dst,
                             int dst_pos,
                             int length)
Inserts a table slice into another table. The table will be entirely or partially inserted into the table.

Parameters:
src - Tablea to insert into .
src_pos - Index of the first data item of to insert into .
dst - Table in which to insert data.
dst_pos - index in which to insert data. All elements of whose index is equal to or greater than will be moved forward.
length - Number of data items to insert.
Returns:
Table which contains the combination of and . This method can directly return , but never . It most often returns a newly created table.

insert

public static byte[] insert(byte[] src,
                            int src_pos,
                            byte[] dst,
                            int dst_pos,
                            int length)
Inserts a table slice into another table. The table will be entirely or partially inserted into the table.

Parameters:
src - Tablea to insert into .
src_pos - Index of the first data item of to insert into .
dst - Table in which to insert data.
dst_pos - index in which to insert data. All elements of whose index is equal to or greater than will be moved forward.
length - Number of data items to insert.
Returns:
Table which contains the combination of and . This method can directly return , but never . It most often returns a newly created table.

insert

public static char[] insert(char[] src,
                            int src_pos,
                            char[] dst,
                            int dst_pos,
                            int length)
Inserts a table slice into another table. The table will be entirely or partially inserted into the table.

Parameters:
src - Tablea to insert into .
src_pos - Index of the first data item of to insert into .
dst - Table in which to insert data.
dst_pos - index in which to insert data. All elements of whose index is equal to or greater than will be moved forward.
length - Number of data items to insert.
Returns:
Table which contains the combination of and . This method can directly return , but never . It most often returns a newly created table.

insert

public static boolean[] insert(boolean[] src,
                               int src_pos,
                               boolean[] dst,
                               int dst_pos,
                               int length)
Inserts a table slice into another table. The table will be entirely or partially inserted into the table.

Parameters:
src - Tablea to insert into .
src_pos - Index of the first data item of to insert into .
dst - Table in which to insert data.
dst_pos - index in which to insert data. All elements of whose index is equal to or greater than will be moved forward.
length - Number of data items to insert.
Returns:
Table which contains the combination of and . This method can directly return , but never . It most often returns a newly created table.

isSorted

public static boolean isSorted(char[] array)
Returns if all elements in the specified array are in increasing order. This method is usefull in assertions.


isSorted

public static boolean isSorted(byte[] array)
Returns if all elements in the specified array are in increasing order. This method is usefull in assertions.


isSorted

public static boolean isSorted(short[] array)
Returns if all elements in the specified array are in increasing order. This method is usefull in assertions.


isSorted

public static boolean isSorted(int[] array)
Returns if all elements in the specified array are in increasing order. This method is usefull in assertions.


isSorted

public static boolean isSorted(long[] array)
Returns if all elements in the specified array are in increasing order. This method is usefull in assertions.


isSorted

public static boolean isSorted(float[] array)
Returns if all elements in the specified array are in increasing order. Since values are unordered, they may appears anywhere in the array; they will be ignored. This method is usefull in assertions.


isSorted

public static boolean isSorted(double[] array)
Returns if all elements in the specified array are in increasing order. Since values are unordered, they may appears anywhere in the array; they will be ignored. This method is usefull in assertions.


isStrictlySorted

public static boolean isStrictlySorted(int[] array)
Returns if all elements in the specified array are in strictly increasing order. This method is usefull in assertions.


hasNaN

public static boolean hasNaN(double[] array)
Returns if the specified array contains at least one NaN value.


hasNaN

public static boolean hasNaN(float[] array)
Returns if the specified array contains at least one NaN value.


toString

public static java.lang.String toString(java.lang.Object array,
                                        java.util.Locale locale)
Returns a string representation of an array of numbers. Current implementation supports only primitive or subclasses of Number.

Parameters:
array - The array to format.
locale - The locale for formatting.
Returns:
The formatted array.
To Do:
The separator should be local-dependent., Should we implements this functionality in LineFormat instead?


Copyright © GeoTools. All Rights Reserved.