Class PCollections


  • public final class PCollections
    extends Object
    Utilities for working with persistent collections.

    These are in three categories: converting from JDK collections to persistent ones, Stream helpers, and shorthand factory methods.

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <K,​V>
      org.pcollections.PMap<K,​V>
      asMap​(Map<K,​V> map)  
      static <KI,​VI,​KO,​VO>
      org.pcollections.PMap<KO,​VO>
      asMap​(Map<KI,​VI> map, BiFunction<KI,​VI,​KO> keyMapper, BiFunction<KI,​VI,​VO> valueMapper)  
      static <I,​O>
      org.pcollections.PSet<O>
      asSet​(Iterable<I> list, Function<? super I,​? extends O> xform)  
      static <E> org.pcollections.PSet<E> asSet​(Collection<E> set)  
      static <I,​O>
      org.pcollections.PStack<O>
      asStack​(Iterable<I> list, Function<? super I,​? extends O> xform)  
      static <E> org.pcollections.PStack<E> asStack​(Collection<E> stack)  
      static <I,​O>
      org.pcollections.PVector<O>
      asVector​(Iterable<I> list, Function<? super I,​? extends O> xform)  
      static <E> org.pcollections.PVector<E> asVector​(Collection<E> list)  
      static <K,​V>
      org.pcollections.PMap<K,​V>
      map()  
      static <K,​V>
      org.pcollections.PMap<K,​V>
      map​(K key, V value)  
      static <E1 extends E2,​E2>
      org.pcollections.PBag<E2>
      narrow​(org.pcollections.PBag<E1> input)  
      static <K1 extends K2,​V1 extends V2,​K2,​V2>
      org.pcollections.PMap<K2,​V2>
      narrow​(org.pcollections.PMap<K1,​V1> input)  
      static <E1 extends E2,​E2>
      org.pcollections.PSet<E2>
      narrow​(org.pcollections.PSet<E1> input)  
      static <E1 extends E2,​E2>
      org.pcollections.PStack<E2>
      narrow​(org.pcollections.PStack<E1> input)  
      static <E1 extends E2,​E2>
      org.pcollections.PVector<E2>
      narrow​(org.pcollections.PVector<E1> input)  
      static <E> org.pcollections.PSet<E> set()  
      static <E> org.pcollections.PSet<E> set​(E element)  
      static <E> org.pcollections.PSet<E> set​(E... elements)  
      static <E> org.pcollections.PStack<E> stack()  
      static <E> org.pcollections.PStack<E> stack​(E element)  
      static <E> org.pcollections.PStack<E> stack​(E... elements)  
      static <K,​V>
      Collector<Map.Entry<K,​V>,​?,​org.pcollections.PMap<K,​V>>
      toPMap()  
      static <E> Collector<E,​?,​org.pcollections.PSet<E>> toPSet()  
      static <E> Collector<E,​?,​org.pcollections.PStack<E>> toPStack()  
      static <E> Collector<E,​?,​org.pcollections.PVector<E>> toPVector()  
      static <E> org.pcollections.PVector<E> vector()  
      static <E> org.pcollections.PVector<E> vector​(E element)  
      static <E> org.pcollections.PVector<E> vector​(E... elements)  
    • Method Detail

      • asMap

        public static <K,​V> org.pcollections.PMap<K,​V> asMap​(Map<K,​V> map)
      • asMap

        public static <KI,​VI,​KO,​VO> org.pcollections.PMap<KO,​VO> asMap​(Map<KI,​VI> map,
                                                                                               BiFunction<KI,​VI,​KO> keyMapper,
                                                                                               BiFunction<KI,​VI,​VO> valueMapper)
      • asSet

        public static <E> org.pcollections.PSet<E> asSet​(Collection<E> set)
      • asSet

        public static <I,​O> org.pcollections.PSet<O> asSet​(Iterable<I> list,
                                                                 Function<? super I,​? extends O> xform)
      • asVector

        public static <E> org.pcollections.PVector<E> asVector​(Collection<E> list)
      • asVector

        public static <I,​O> org.pcollections.PVector<O> asVector​(Iterable<I> list,
                                                                       Function<? super I,​? extends O> xform)
      • asStack

        public static <E> org.pcollections.PStack<E> asStack​(Collection<E> stack)
      • asStack

        public static <I,​O> org.pcollections.PStack<O> asStack​(Iterable<I> list,
                                                                     Function<? super I,​? extends O> xform)
      • toPSet

        public static <E> Collector<E,​?,​org.pcollections.PSet<E>> toPSet()
      • toPVector

        public static <E> Collector<E,​?,​org.pcollections.PVector<E>> toPVector()
      • toPStack

        public static <E> Collector<E,​?,​org.pcollections.PStack<E>> toPStack()
      • narrow

        public static <K1 extends K2,​V1 extends V2,​K2,​V2> org.pcollections.PMap<K2,​V2> narrow​(org.pcollections.PMap<K1,​V1> input)
      • narrow

        public static <E1 extends E2,​E2> org.pcollections.PSet<E2> narrow​(org.pcollections.PSet<E1> input)
      • narrow

        public static <E1 extends E2,​E2> org.pcollections.PVector<E2> narrow​(org.pcollections.PVector<E1> input)
      • narrow

        public static <E1 extends E2,​E2> org.pcollections.PStack<E2> narrow​(org.pcollections.PStack<E1> input)
      • narrow

        public static <E1 extends E2,​E2> org.pcollections.PBag<E2> narrow​(org.pcollections.PBag<E1> input)
      • map

        public static <K,​V> org.pcollections.PMap<K,​V> map()
      • map

        public static <K,​V> org.pcollections.PMap<K,​V> map​(K key,
                                                                       V value)
      • set

        public static <E> org.pcollections.PSet<E> set()
      • set

        public static <E> org.pcollections.PSet<E> set​(E element)
      • set

        @SafeVarargs
        public static <E> org.pcollections.PSet<E> set​(E... elements)
      • vector

        public static <E> org.pcollections.PVector<E> vector()
      • vector

        public static <E> org.pcollections.PVector<E> vector​(E element)
      • vector

        @SafeVarargs
        public static <E> org.pcollections.PVector<E> vector​(E... elements)
      • stack

        public static <E> org.pcollections.PStack<E> stack()
      • stack

        public static <E> org.pcollections.PStack<E> stack​(E element)
      • stack

        @SafeVarargs
        public static <E> org.pcollections.PStack<E> stack​(E... elements)