@Override default SynchronousQueue<T> get(Collection<T> collection) { SynchronousQueue<T> ret = new SynchronousQueue<T>(); if(collection!=null){ ret.addAll(collection); } return ret; }
/** * A function that converts lists to synchronous queues. * * @param fair The argument to pass to the constructor of the synchronous queue. * @return A function that converts lists to synchronous queues. */ public static <A> F<List<A>, SynchronousQueue<A>> List_SynchronousQueue(final boolean fair) { return as -> { final SynchronousQueue<A> q = new SynchronousQueue<>(fair); q.addAll(as.toCollection()); return q; }; }
/** * A function that converts options to synchronous queues. * * @param fair The argument to pass to the constructor of the synchronous queue. * @return A function that converts options to synchronous queues. */ public static <A> F<Option<A>, SynchronousQueue<A>> Option_SynchronousQueue(final boolean fair) { return as -> { final SynchronousQueue<A> q = new SynchronousQueue<>(fair); q.addAll(as.toCollection()); return q; }; }
/** * A function that converts arrays to synchronous queues. * * @param fair The argument to pass to the constructor of the synchronous queue. * @return A function that converts arrays to synchronous queues. */ public static <A> F<Array<A>, SynchronousQueue<A>> Array_SynchronousQueue(final boolean fair) { return as -> { final SynchronousQueue<A> q = new SynchronousQueue<>(fair); q.addAll(as.asJavaList()); return q; }; }
/** * A function that converts streams to synchronous queues. * * @param fair The argument to pass to the constructor of the synchronous queue. * @return A function that converts streams to synchronous queues. */ public static <A> F<Stream<A>, SynchronousQueue<A>> Stream_SynchronousQueue(final boolean fair) { return as -> { final SynchronousQueue<A> q = new SynchronousQueue<>(fair); q.addAll(as.toCollection()); return q; }; }
/** * Maps this function over a SynchronousQueue. * * @param as A SynchronousQueue to map this function over. * @return A new SynchronousQueue with this function applied to each element. */ public static <A, B> SynchronousQueue<B> mapJ(final F<A, B> f, final SynchronousQueue<A> as) { final SynchronousQueue<B> bs = new SynchronousQueue<>(); bs.addAll(iterableStream(as).map(f).toCollection()); return bs; }