- java.lang.Object
-
- com.jongsoft.lang.Collections
-
public class Collections extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description Collections()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Iterator<T>Iterator(java.lang.Iterable<T> iterable)Create a new Iterator wrapping the provided iterable.static <T> Iterator<T>Iterator(T... elements)Creates a Iterator that contains all the provided elements.static <T> Sequence<T>List(Iterator<T> iterator)Create a newSequencecontaining all the elements in theiterator.static <T> Sequence<T>List(java.lang.Iterable<? extends T> elements)Creates a newSequencewith all the elements contained in theIterable.static <T> Sequence<T>List(T element)Creates anSequencecontaining exactly one element, being the one passed to this call.static <T> Sequence<T>List(T... elements)Creates a newSequencewith the provided elements as the contents.static <K,T>
Map<K,T>Map()Create a new emptyMap.static <K,T>
Map<K,T>Map(K key, T value)Create a new map with one pair in it being the providedkey,value.static <T> Set<T>Set(java.lang.Iterable<? extends T> iterable)Create a new set containing all the elements of theiterable.static <T> Set<T>Set(java.util.Comparator<T> comparator, java.lang.Iterable<? extends T> iterable)Creates a new Sorted Set with the providedcomparatorand all elements that are in the providediterable.static <T> Set<T>Set(java.util.Comparator<T> comparator, T... elements)Create a new sorted set with all theelementsin it sorted by the providedcomparator.static <T> Set<T>Set(T... elements)Create a new set containing all unique elements.static <T> Set<T>SortedSet()static <T> Tree<T>Tree(java.lang.String label, T rootValue)static <T> Tree<T>Tree(java.lang.String label, T value, java.lang.Iterable<Tree<T>> children)
-
-
-
Method Detail
-
Tree
public static <T> Tree<T> Tree(java.lang.String label, T rootValue)
-
Tree
public static <T> Tree<T> Tree(java.lang.String label, T value, java.lang.Iterable<Tree<T>> children)
-
List
public static <T> Sequence<T> List(T element)
Creates anSequencecontaining exactly one element, being the one passed to this call.- Type Parameters:
T- the type of the element- Parameters:
element- the element to add to the new array- Returns:
- the new array list
-
List
@SafeVarargs public static <T> Sequence<T> List(T... elements)
Creates a newSequencewith the provided elements as the contents.- Type Parameters:
T- the type that the elements represent- Parameters:
elements- the elements to add to the array- Returns:
- the new array list
- Throws:
java.lang.NullPointerException- ifelementsis null
-
List
public static <T> Sequence<T> List(java.lang.Iterable<? extends T> elements)
Creates a newSequencewith all the elements contained in theIterable.- Type Parameters:
T- the type of the elements- Parameters:
elements- the elements that should be in the new array- Returns:
- the new array
-
List
public static <T> Sequence<T> List(Iterator<T> iterator)
Create a newSequencecontaining all the elements in theiterator.- Type Parameters:
T- the type of the elements- Parameters:
iterator- the iterator to copy into the array- Returns:
- the newly created array
- Throws:
java.lang.NullPointerException- ifiteratoris null
-
Set
@SafeVarargs public static <T> Set<T> Set(T... elements)
Create a new set containing all unique elements.- Type Parameters:
T- the type of the elements- Parameters:
elements- the elements for the new set- Returns:
- the created set
-
Set
public static <T> Set<T> Set(java.lang.Iterable<? extends T> iterable)
Create a new set containing all the elements of theiterable.- Type Parameters:
T- the type of the elements- Parameters:
iterable- the iterable containing the elements to add to the set- Returns:
- the created set
- Throws:
java.lang.NullPointerException- ifiterableis null
-
Set
@SafeVarargs public static <T> Set<T> Set(java.util.Comparator<T> comparator, T... elements)
Create a new sorted set with all theelementsin it sorted by the providedcomparator.- Type Parameters:
T- the type of the elements- Parameters:
comparator- the comparator to use for sorting the setelements- the elements initially in the set- Returns:
- the newly generated sorted set
-
Set
public static <T> Set<T> Set(java.util.Comparator<T> comparator, java.lang.Iterable<? extends T> iterable)
Creates a new Sorted Set with the providedcomparatorand all elements that are in the providediterable.- Type Parameters:
T- the type of the elements- Parameters:
comparator- the comparator to use for sorting the setiterable- the iterable whose elements to copy into the new set- Returns:
- the newly generated sorted set
-
SortedSet
public static <T> Set<T> SortedSet()
-
Map
public static <K,T> Map<K,T> Map()
Create a new emptyMap.- Type Parameters:
K- the type of the keyT- the type of the balue- Returns:
- the new empty map
-
Map
public static <K,T> Map<K,T> Map(K key, T value)
Create a new map with one pair in it being the providedkey,value.- Type Parameters:
K- the type of the keyT- the type of the balue- Parameters:
key- the key use for the first elementvalue- the value use for the first element- Returns:
- the new map
-
Iterator
@SafeVarargs public static <T> Iterator<T> Iterator(T... elements)
Creates a Iterator that contains all the provided elements.- Type Parameters:
T- the type of the elements- Parameters:
elements- the elements to wrap in an iterator- Returns:
- the new iterator
-
Iterator
public static <T> Iterator<T> Iterator(java.lang.Iterable<T> iterable)
Create a new Iterator wrapping the provided iterable.- Type Parameters:
T- the type of elements in the iterable- Parameters:
iterable- the iterable to wrap- Returns:
- the iterator wrapping the iterable
- Throws:
java.lang.NullPointerException- ifiterableis null
-
-