Package adams.data.binning.operation
Class Wrapping
- java.lang.Object
-
- adams.data.binning.operation.Wrapping
-
public class Wrapping extends Object
For wrapping data.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
Wrapping.BinValueExtractor<T>
Interface for extracting values for bins from arbitrary objects.static class
Wrapping.IndexedBinValueExtractor<T>
Simply keeps track of the number of objects encountered and returns that count as bin value.
-
Constructor Summary
Constructors Constructor Description Wrapping()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> List<Binnable<T>>
addTmpIndex(List<Binnable<T>> data)
Adds the list index under a temporary keyTMP_INDEX
.static <T> gnu.trove.list.TIntList
getTmpIndices(List<Binnable<T>> data)
Collects indices stored underTMP_INDEX
.static <T> List<Binnable<T>>
removeTmpIndex(List<Binnable<T>> data)
Removes the list index under a temporary keyTMP_INDEX
.static <T> List<T>
unwrap(List<Binnable<T>> data)
Unwraps the payloads from the binnable list.static List<Binnable<Integer>>
wrap(double[] values)
Wraps the double array in binnable objects, using the index as payload.static List<Binnable<Integer>>
wrap(float[] values)
Wraps the float array in binnable objects, using the index as payload.static List<Binnable<Integer>>
wrap(Number[] values)
Wraps the double array in binnable objects, using the index as payload.static List<Binnable<Integer>>
wrap(Collection<Number> values)
Wraps the double array in binnable objects, using the index as payload.static <T> List<Binnable<T>>
wrap(Collection<T> values, Wrapping.BinValueExtractor<T> extractor)
Wraps the collection in binnable objects, using the extractor to determine the value for the binnable object.static <T> List<Binnable<T>>
wrap(T[] values, Wrapping.BinValueExtractor<T> extractor)
Wraps the array in binnable objects, using the extractor to determine the value for the binnable object.static <T> List<Binnable<BinnableGroup<T>>>
wrapGroups(Collection<BinnableGroup<T>> values, Wrapping.BinValueExtractor<T> extractor)
Wraps the collection of binnable group objects in binnable objects, using the extractor to determine the value for the binnable object (uses first item of group).
-
-
-
Field Detail
-
TMP_INDEX
public static final String TMP_INDEX
the temporary index stored in the binnable meta-data.- See Also:
- Constant Field Values
-
-
Method Detail
-
wrap
public static List<Binnable<Integer>> wrap(double[] values) throws Exception
Wraps the double array in binnable objects, using the index as payload.- Parameters:
values
- the values to wrap- Returns:
- the wrapped indices/values
- Throws:
Exception
- if NaN value is encountered
-
wrap
public static List<Binnable<Integer>> wrap(float[] values) throws Exception
Wraps the float array in binnable objects, using the index as payload.- Parameters:
values
- the values to wrap- Returns:
- the wrapped indices/values
- Throws:
Exception
- if NaN value is encountered
-
wrap
public static List<Binnable<Integer>> wrap(Number[] values) throws Exception
Wraps the double array in binnable objects, using the index as payload.- Parameters:
values
- the values to wrap- Returns:
- the wrapped indices/values
- Throws:
Exception
- if NaN value is encountered
-
wrap
public static List<Binnable<Integer>> wrap(Collection<Number> values) throws Exception
Wraps the double array in binnable objects, using the index as payload.- Parameters:
values
- the values to wrap- Returns:
- the wrapped indices/values
- Throws:
Exception
- if NaN value is encountered
-
wrap
public static <T> List<Binnable<T>> wrap(T[] values, Wrapping.BinValueExtractor<T> extractor) throws Exception
Wraps the array in binnable objects, using the extractor to determine the value for the binnable object.- Parameters:
values
- the values to wrapextractor
- for extracting the bin value from the objects- Returns:
- the wrapped values
- Throws:
Exception
-
wrap
public static <T> List<Binnable<T>> wrap(Collection<T> values, Wrapping.BinValueExtractor<T> extractor) throws Exception
Wraps the collection in binnable objects, using the extractor to determine the value for the binnable object.- Parameters:
values
- the values to wrapextractor
- for extracting the value from the objects- Returns:
- the wrapped values
- Throws:
Exception
-
wrapGroups
public static <T> List<Binnable<BinnableGroup<T>>> wrapGroups(Collection<BinnableGroup<T>> values, Wrapping.BinValueExtractor<T> extractor) throws Exception
Wraps the collection of binnable group objects in binnable objects, using the extractor to determine the value for the binnable object (uses first item of group).- Parameters:
values
- the values to wrapextractor
- for extracting the value from the objects- Returns:
- the wrapped values
- Throws:
Exception
-
unwrap
public static <T> List<T> unwrap(List<Binnable<T>> data)
Unwraps the payloads from the binnable list.- Type Parameters:
T
- the type of payload- Parameters:
data
- the data to unwrap- Returns:
- the payload list
-
addTmpIndex
public static <T> List<Binnable<T>> addTmpIndex(List<Binnable<T>> data)
Adds the list index under a temporary keyTMP_INDEX
.- Type Parameters:
T
- the payload type- Parameters:
data
- the data to enumerate- Returns:
- the updated (input)
-
getTmpIndices
public static <T> gnu.trove.list.TIntList getTmpIndices(List<Binnable<T>> data)
Collects indices stored underTMP_INDEX
.- Parameters:
data
- the data to retrieve the indices from- Returns:
- the indices
-
-