public static <E> PVector<E> vector() { return TreePVector.empty(); }
public static <E> PVector<E> vector() { return TreePVector.empty(); }
/** * @param <E> * @param e * @return empty().plus(e) */ public static <E> TreePVector<E> singleton(final E e) { return TreePVector.<E>empty().plus(e); }
/** * @param <E> * @param e * @return empty().plus(e) */ public static <E> TreePVector<E> singleton(final E e) { return TreePVector.<E>empty().plus(e); }
/** * @param <E> * @param list * @return empty().plusAll(list) */ @SuppressWarnings("unchecked") public static <E> TreePVector<E> from(final Collection<? extends E> list) { if(list instanceof TreePVector) return (TreePVector<E>)list; //(actually we only know it's TreePVector<? extends E>) // but that's good enough for an immutable // (i.e. we can't mess someone else up by adding the wrong type to it) return TreePVector.<E>empty().plusAll(list); }
/** * @param <E> * @param list * @return empty().plusAll(list) */ @SuppressWarnings("unchecked") public static <E> TreePVector<E> from(final Collection<? extends E> list) { if(list instanceof TreePVector) return (TreePVector<E>)list; //(actually we only know it's TreePVector<? extends E>) // but that's good enough for an immutable // (i.e. we can't mess someone else up by adding the wrong type to it) return TreePVector.<E>empty().plusAll(list); }
public void testVectorExceptions() { sequenceExceptions(TreePVector.<Integer>empty()); }
@Override public TreePVector<E> subList(final int start, final int end) { final int size = size(); if(start<0 || end>size || start>end) throw new IndexOutOfBoundsException(); if(start==end) return empty(); if(start==0) { if(end==size) return this; // remove from end: return this.minus(size-1).subList(start, end); } // remove from start: return this.minus(0).subList(start-1,end-1); }
@Override public TreePVector<E> subList(final int start, final int end) { final int size = size(); if(start<0 || end>size || start>end) throw new IndexOutOfBoundsException(); if(start==end) return empty(); if(start==0) { if(end==size) return this; // remove from end: return this.minus(size-1).subList(start, end); } // remove from start: return this.minus(0).subList(start-1,end-1); }
@Override protected TreePVector<Object> createEmptyCollection() { return TreePVector.empty(); } }
private AnInstance(Class<? extends T> klass) { this.klass = klass; matchers = TreePVector.empty(); }
public static <E> PVector<E> vector() { return TreePVector.empty(); }
PVector<Integer> pvec = TreePVector.empty(); List<Integer> list = new LinkedList<Integer>(); Random r = new Random(); UtilityTest.assertEqualsAndHash(TreePVector.empty(), pvec.minusAll(pvec)); UtilityTest.assertEqualsAndHash(pvec, TreePVector.empty().plusAll(pvec)); UtilityTest.assertEqualsAndHash(pvec, TreePVector.singleton(10).plusAll(1,pvec).minus(0));
/** * @param col Collection. * @param evt Event. * @return Cloned collection. */ protected static <E> Collection<E> addToCollection(@Nullable Collection<E> col, E evt) { PVector<E> res = col == null ? TreePVector.<E>empty() : (PVector<E>)col; return res.plus(evt); }
/** * @param <E> * @param e * @return empty().plus(e) */ public static <E> TreePVector<E> singleton(final E e) { return TreePVector.<E>empty().plus(e); }
/** * @param <E> * @param e * @return empty().plus(e) */ public static <E> TreePVector<E> singleton(final E e) { return TreePVector.<E>empty().plus(e); }
/** * @param <E> * @param list * @return empty().plusAll(list) */ @SuppressWarnings("unchecked") public static <E> TreePVector<E> from(final Collection<? extends E> list) { if(list instanceof TreePVector) return (TreePVector<E>)list; //(actually we only know it's TreePVector<? extends E>) // but that's good enough for an immutable // (i.e. we can't mess someone else up by adding the wrong type to it) return TreePVector.<E>empty().plusAll(list); }
/** * @param <E> * @param list * @return empty().plusAll(list) */ @SuppressWarnings("unchecked") public static <E> TreePVector<E> from(final Collection<? extends E> list) { if (list instanceof TreePVector) return (TreePVector<E>) list; //(actually we only know it's TreePVector<? extends E>) // but that's good enough for an immutable // (i.e. we can't mess someone else up by adding the wrong type to it) return TreePVector.<E>empty().plusAll(list); }
public static <T> Monoid<PVector<T>> toPVector() { return Monoid.<PVector<T>>of(TreePVector .empty(), (PVector<T> a) -> b -> a.plusAll(b), (T x) -> TreePVector.singleton(x)); } public static <T> Monoid<PStack<T>> toPStack() {
private Object build( ComprehensionData c, Function f) { Mutable<PVector<String>> vars = new Mutable<>(TreePVector.empty()); getAssigned().stream().forEach(e-> addToVar(e,vars,handleNext(e,c,vars.get()))); Mutable<Object> var = new Mutable<>(f); return c.yield(()-> { return unwrapNestedFunction(c, f, vars.get()); } ); } private Object unwrapNestedFunction(ComprehensionData c, Function f,