Class AWUtil
- java.lang.Object
-
- net.automatalib.common.smartcollection.AWUtil
-
public final class AWUtil extends Object
Utility class for writing containers to arrays.It is generally preferable to use the static methods this class offers than using
ArrayWritable.writeToArray(int, Object[], int, int)
directly.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T,U extends T>
intsafeWrite(int num, ArrayWritable<U> aw, int ofs, T[] array, int tgtOfs)
static <T,U extends T>
intsafeWrite(int num, ArrayWritable<U> aw, T[] array)
Writes a given maximum amount of data items from a container to an array.static <T,U extends T>
intsafeWrite(ArrayWritable<U> aw, T[] array)
Writes the complete container data to an array.static <T,U extends T>
intsafeWrite(ArrayWritable<U> aw, T[] array, int tgtOfs)
static Object[]
toArray(ArrayWritable<?> aw)
static <T> T[]
toArray(ArrayWritable<?> aw, T[] arr)
-
-
-
Method Detail
-
safeWrite
public static <T,U extends T> int safeWrite(ArrayWritable<U> aw, T[] array)
Writes the complete container data to an array. This method ensures that the array's capacity is not exceeded.- Type Parameters:
T
- the array typeU
- the container type- Parameters:
aw
- the container.array
- the array- Returns:
- the number of elements copied
-
safeWrite
public static <T,U extends T> int safeWrite(int num, ArrayWritable<U> aw, T[] array)
Writes a given maximum amount of data items from a container to an array. This method ensures that the array's capacity is not exceeded.- Type Parameters:
T
- the array typeU
- the container type- Parameters:
num
- the number of elements to copyaw
- the container.array
- the array- Returns:
- the number of elements copied
-
safeWrite
public static <T,U extends T> int safeWrite(int num, ArrayWritable<U> aw, int ofs, T[] array, int tgtOfs)
-
safeWrite
public static <T,U extends T> int safeWrite(ArrayWritable<U> aw, T[] array, int tgtOfs)
-
toArray
public static Object[] toArray(ArrayWritable<?> aw)
-
toArray
public static <T> T[] toArray(ArrayWritable<?> aw, T[] arr)
-
-