Class 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 new Sequence containing all the elements in the iterator.
      static <T> Sequence<T> List​(java.lang.Iterable<? extends T> elements)
      Creates a new Sequence with all the elements contained in the Iterable.
      static <T> Sequence<T> List​(T element)
      Creates an Sequence containing exactly one element, being the one passed to this call.
      static <T> Sequence<T> List​(T... elements)
      Creates a new Sequence with the provided elements as the contents.
      static <K,​T>
      Map<K,​T>
      Map()
      Create a new empty Map.
      static <K,​T>
      Map<K,​T>
      Map​(K key, T value)
      Create a new map with one pair in it being the provided key, value.
      static <T> Set<T> Set​(java.lang.Iterable<? extends T> iterable)
      Create a new set containing all the elements of the iterable.
      static <T> Set<T> Set​(java.util.Comparator<T> comparator, java.lang.Iterable<? extends T> iterable)
      Creates a new Sorted Set with the provided comparator and all elements that are in the provided iterable.
      static <T> Set<T> Set​(java.util.Comparator<T> comparator, T... elements)
      Create a new sorted set with all the elements in it sorted by the provided comparator.
      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)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Collections

        public Collections()
    • 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 an Sequence containing 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 new Sequence with 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 - if elements is null
      • List

        public static <T> Sequence<T> List​(java.lang.Iterable<? extends T> elements)
        Creates a new Sequence with all the elements contained in the Iterable.
        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 new Sequence containing all the elements in the iterator.
        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 - if iterator is 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 the iterable.
        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 - if iterable is null
      • Set

        @SafeVarargs
        public static <T> Set<T> Set​(java.util.Comparator<T> comparator,
                                     T... elements)
        Create a new sorted set with all the elements in it sorted by the provided comparator.
        Type Parameters:
        T - the type of the elements
        Parameters:
        comparator - the comparator to use for sorting the set
        elements - 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 provided comparator and all elements that are in the provided iterable.
        Type Parameters:
        T - the type of the elements
        Parameters:
        comparator - the comparator to use for sorting the set
        iterable - 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 empty Map.
        Type Parameters:
        K - the type of the key
        T - 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 provided key, value.
        Type Parameters:
        K - the type of the key
        T - the type of the balue
        Parameters:
        key - the key use for the first element
        value - 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 - if iterable is null