public class MyCollections extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
MyCollections.IToString |
Modifier and Type | Field and Description |
---|---|
static MyCollections.IToString |
TO_STRING |
Constructor and Description |
---|
MyCollections() |
Modifier and Type | Method and Description |
---|---|
static <T> List<T> |
asList(Collection<T> objects) |
static <T> List<T> |
asList(Collection<T> objects,
IFilter filter) |
static <T> List<T> |
asList(Collection<T> objects,
ObjectFilter filter) |
static <T> List<T> |
asList(T[] objects) |
static <T> List<T> |
asList(T[] objects,
IFilter filter) |
static <T> List<T> |
asList(T[] objects,
ObjectFilter filter) |
static <T> List<T> |
getFiltered(Collection<T> col,
IFilter filter)
Returns new list that contains only objects from 'col' that are
IFilter.isAccepted(Object) . |
static <T> T[] |
getFiltered(T[] array,
IFilter filter)
Returns new array that contains only objects from 'array' that are
IFilter.isAccepted(Object) . |
static <T> T |
getRandom(Collection<T> col)
Returns random element from the collection.
|
static <T> T |
getRandom(List<T> list)
Returns random element from the list.
|
static <T> T |
getRandom(T[] array)
Returns random element from the array.
|
static <T> T |
getRandomFiltered(Collection<T> col,
IFilter filter)
Returns random element from the collection that is
IFilter.isAccepted(Object) by the 'filter'. |
static <T> T |
getRandomFiltered(T[] array,
IFilter filter)
Returns random element from the array that is
IFilter.isAccepted(Object) by the 'filter'. |
static <T> void |
toCollection(T[] array,
Collection<T> col)
Moves data from 'array' to 'col'.
|
static <T> void |
toList(T[] objects,
List<T> list)
Adds 'objects' to 'list'.
|
static <T> void |
toList(T[] objects,
List<T> list,
IFilter filter)
Adds 'objects' that satisfies 'filter' to 'list'.
|
static <T> void |
toList(T[] objects,
List<T> list,
ObjectFilter filter)
Adds 'objects' that satisfies 'filter' to 'list'.
|
static String |
toString(Object objToString,
String[] prefixes,
String[] postfixes,
String[] separators,
MyCollections.IToString toString) |
static String |
toString(Object obj,
String prefix,
String postfix,
String separator) |
static String |
toString(Object obj,
String prefix,
String postfix,
String separator,
MyCollections.IToString toString) |
public static final MyCollections.IToString TO_STRING
public static <T> List<T> getFiltered(Collection<T> col, IFilter filter)
IFilter.isAccepted(Object)
.T
- col
- filter
- public static <T> T[] getFiltered(T[] array, IFilter filter)
IFilter.isAccepted(Object)
.T
- col
- filter
- public static <T> T getRandom(Collection<T> col)
WARNING: O(n) time complexity in the worst case scenario!
T
- col
- public static <T> T getRandom(List<T> list)
O(1) time complexity.
T
- list
- public static <T> T getRandom(T[] array)
T
- array
- public static <T> T getRandomFiltered(Collection<T> col, IFilter filter)
IFilter.isAccepted(Object)
by the 'filter'.
WARNING: O(n) time complexity in the worst case scenario!
T
- col
- filter
- if null, performs getRandom(Collection)
public static <T> T getRandomFiltered(T[] array, IFilter filter)
IFilter.isAccepted(Object)
by the 'filter'.T
- array
- public static <T> void toList(T[] objects, List<T> list)
T
- objects
- list
- public static <T> void toList(T[] objects, List<T> list, ObjectFilter filter)
T
- objects
- list
- filter
- public static <T> void toList(T[] objects, List<T> list, IFilter filter)
T
- objects
- list
- filter
- public static <T> List<T> asList(T[] objects)
public static <T> List<T> asList(Collection<T> objects)
public static <T> List<T> asList(T[] objects, ObjectFilter filter)
public static <T> List<T> asList(Collection<T> objects, ObjectFilter filter)
public static <T> List<T> asList(Collection<T> objects, IFilter filter)
public static String toString(Object objToString, String[] prefixes, String[] postfixes, String[] separators, MyCollections.IToString toString)
public static String toString(Object obj, String prefix, String postfix, String separator, MyCollections.IToString toString)
public static <T> void toCollection(T[] array, Collection<T> col)
array
- col
- Copyright © 2012 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.