cz.cuni.amis.utils.collections
Class MyCollections

java.lang.Object
  extended by cz.cuni.amis.utils.collections.MyCollections

public class MyCollections
extends java.lang.Object


Nested Class Summary
static interface MyCollections.IToString
           
 
Field Summary
static MyCollections.IToString TO_STRING
           
 
Constructor Summary
MyCollections()
           
 
Method Summary
static
<T> java.util.List<T>
asList(java.util.Collection<T> objects)
           
static
<T> java.util.List<T>
asList(java.util.Collection<T> objects, ObjectFilter filter)
           
static
<T> java.util.List<T>
asList(T[] objects)
           
static
<T> java.util.List<T>
asList(T[] objects, ObjectFilter filter)
           
static
<T> T
getRandom(java.util.Collection<T> col)
          Returns random element from the collection.
static
<T> T
getRandom(java.util.List<T> list)
          Returns random element from the list.
static
<T> T
getRandom(T[] array)
          Returns random element from the array.
static
<T> void
toList(T[] objects, java.util.List<T> list)
           
static
<T> void
toList(T[] objects, java.util.List<T> list, ObjectFilter filter)
           
static java.lang.String toString(java.lang.Object objToString, java.lang.String[] prefixes, java.lang.String[] postfixes, java.lang.String[] separators, MyCollections.IToString toString)
           
static java.lang.String toString(java.lang.Object obj, java.lang.String prefix, java.lang.String postfix, java.lang.String separator)
           
static java.lang.String toString(java.lang.Object obj, java.lang.String prefix, java.lang.String postfix, java.lang.String separator, MyCollections.IToString toString)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TO_STRING

public static final MyCollections.IToString TO_STRING
Constructor Detail

MyCollections

public MyCollections()
Method Detail

getRandom

public static <T> T getRandom(java.util.Collection<T> col)
Returns random element from the collection.

WARNING: O(n) time complexity in the worst case scenario!

Type Parameters:
T -
Parameters:
col -
Returns:

getRandom

public static <T> T getRandom(java.util.List<T> list)
Returns random element from the list.

O(1) time complexity.

Type Parameters:
T -
Parameters:
list -
Returns:

getRandom

public static <T> T getRandom(T[] array)
Returns random element from the array.

Type Parameters:
T -
Parameters:
array -
Returns:

toList

public static <T> void toList(T[] objects,
                              java.util.List<T> list)

toList

public static <T> void toList(T[] objects,
                              java.util.List<T> list,
                              ObjectFilter filter)

asList

public static <T> java.util.List<T> asList(T[] objects)

asList

public static <T> java.util.List<T> asList(java.util.Collection<T> objects)

asList

public static <T> java.util.List<T> asList(T[] objects,
                                           ObjectFilter filter)

asList

public static <T> java.util.List<T> asList(java.util.Collection<T> objects,
                                           ObjectFilter filter)

toString

public static java.lang.String toString(java.lang.Object objToString,
                                        java.lang.String[] prefixes,
                                        java.lang.String[] postfixes,
                                        java.lang.String[] separators,
                                        MyCollections.IToString toString)

toString

public static java.lang.String toString(java.lang.Object obj,
                                        java.lang.String prefix,
                                        java.lang.String postfix,
                                        java.lang.String separator)

toString

public static java.lang.String toString(java.lang.Object obj,
                                        java.lang.String prefix,
                                        java.lang.String postfix,
                                        java.lang.String separator,
                                        MyCollections.IToString toString)