• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Stream类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中fj.data.Stream的典型用法代码示例。如果您正苦于以下问题:Java Stream类的具体用法?Java Stream怎么用?Java Stream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Stream类属于fj.data包,在下文中一共展示了Stream类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: doubleParser

import fj.data.Stream; //导入依赖的package包/类
private static Parser<Stream<Character>, Double, String> doubleParser() {
	final F<Character, F<Stream<Character>, Stream<Character>>> cons = Streams.cons();
	final F<Stream<Character>, F<Stream<Character>, Stream<Character>>> append = Streams.append();
	final F<Stream<Character>, F<Character, Stream<Character>>> snoc = flip(Streams.<Character>snoc());
	
	final Parser<Stream<Character>, Stream<Character>, String> sign = 
		charParser('-').optional().map(Options.<Character>optionToStream());
	final Parser<Stream<Character>, Stream<Character>, String> digits = 
		digitParser().map(Digit.toChar).repeat1();
	final Parser<Stream<Character>, Stream<Character>, String> dotDigits =
		charParser('.').bind(digits, cons);
	final Parser<Stream<Character>, Stream<Character>, String> digitsDotDigits =
		digits.bind(charParser('.'), snoc).bind(digits, append);
	final Parser<Stream<Character>, Stream<Character>, String> scientific =
		charParser('E').or(charParser('e')).bind(sign.bind(digits, append), cons).optional().map(
			new F<Option<Stream<Character>>, Stream<Character>>() {
				@Override
				public Stream<Character> f(final Option<Stream<Character>> option) {
					return option.orSome(Stream.<Character>nil());
				}
			});
	return sign.bind(dotDigits.or(digitsDotDigits).or(digits), append).bind(scientific, append)
		.map(charStreamToString).map(Doubles.parseDouble).map(Option.<Double>fromSome());
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:25,代码来源:Read.java


示例2: loggerShow

import fj.data.Stream; //导入依赖的package包/类
public static Show<RouteNodeDocumentation> loggerShow(int indent) {
    return Show.show(rnd -> {
        Stream<Character> s = toIndent(indent).append(lparen).append(space).append(Stream.fromString(rnd.label)).append(space).append(rparen).append(nl);
        Stream<Character> withNext =
          rnd.next.isEmpty() ?
          s :
          s.append(mkString(RouteNodeDocumentation.loggerShow(indent + 1), "\n").show(rnd.next));
        return withNext;
    });
}
 
开发者ID:kantega,项目名称:respiro,代码行数:11,代码来源:RouteNodeDocumentation.java


示例3: mkString

import fj.data.Stream; //导入依赖的package包/类
public static <T> Show<List<T>>  mkString(Show<T> s,String separator){
    return Show.show(ts->{
        if(ts.isEmpty())
            return Stream.nil();

        T head = ts.head();
        List<T> tail = ts.tail();

        if(tail.isEmpty())
            return s.show(head);

        else
            return s.show(head).append(Stream.fromString(separator)).append(mkString(s,separator).show(tail));
    });
}
 
开发者ID:kantega,项目名称:respiro,代码行数:16,代码来源:Strings.java


示例4: csvParser

import fj.data.Stream; //导入依赖的package包/类
private static final <A> Parser<Stream<Character>, Stream<A>, String> csvParser(final Parser<Stream<Character>, A, String> pa) {
	return pa.bind(new F<A, Parser<Stream<Character>, Stream<A>, String>>() {
		@Override
		public Parser<Stream<Character>, Stream<A>, String> f(A a) {
			return charParser(',').sequence(csvParser(pa).map(Stream.<A>cons_().f(a)));
		}
	}).or(Read.<Stream<Character>, A, String>nilStreamParser());
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:9,代码来源:Read.java


示例5: nilStreamParser

import fj.data.Stream; //导入依赖的package包/类
private static <I, A, E> Parser<I, Stream<A>, E> nilStreamParser() {
	return Parser.parser(new F<I, Validation<E, Result<I, Stream<A>>>>() {
		@Override
		public Validation<E, Result<I, Stream<A>>> f(final I input) {
			return success(result(input, Stream.<A>nil()));
		}
	});
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:9,代码来源:Read.java


示例6: digitParser

import fj.data.Stream; //导入依赖的package包/类
private static Parser<Stream<Character>, Digit, String> digitParser() {
	return CharsParser.digit("Expected an digit", new F<Character, String>() {
		@Override
		public String f(final Character c) {
			return "Expected a digit but found '" + c + "'";
		}
	});
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:9,代码来源:Read.java


示例7: toList

import fj.data.Stream; //导入依赖的package包/类
public static <A> F<Stream<A>, List<A>> toList() {
	return new F<Stream<A>, List<A>>() {
		@Override
		public List<A> f(final Stream<A> stream	) {
			return stream.toList();
		}
	};
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:9,代码来源:Streams.java


示例8: fromIterator

import fj.data.Stream; //导入依赖的package包/类
public static final <A> Stream<A> fromIterator(final Iterator<A> iterator) {
	if (!iterator.hasNext())
		return nil();
	return Stream.cons(iterator.next(), new P1<Stream<A>>() {
		@Override
		public Stream<A> _1() {
			return fromIterator(iterator);
		}
	});
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:11,代码来源:Streams.java


示例9: unzip

import fj.data.Stream; //导入依赖的package包/类
/**
 * First-class version of {@link Stream#unzip(Stream)}
 */
public static final <A, B> F<Stream<P2<A, B>>, P2<Stream<A>, Stream<B>>> unzip() {
	return new F<Stream<P2<A, B>>, P2<Stream<A>, Stream<B>>>() {
		@Override
		public P2<Stream<A>, Stream<B>> f(final Stream<P2<A, B>> as) {
			return Stream.unzip(as);
		}
	};
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:12,代码来源:Streams.java


示例10: snoc

import fj.data.Stream; //导入依赖的package包/类
public static final <A> F<A, F<Stream<A>, Stream<A>>> snoc() {
	return curry(new F2<A, Stream<A>, Stream<A>>() {
		@Override
		public Stream<A> f(final A a, final Stream<A> as) {
			return as.snoc(a);
		}
	});
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:9,代码来源:Streams.java


示例11: toStream_

import fj.data.Stream; //导入依赖的package包/类
/**
 * Returns a function that transforms a vector-4 to a stream of its elements.
 *
 * @return a function that transforms a vector-4 to a stream of its elements.
 */
public static <A> F<V4<A>, Stream<A>> toStream_() {
  return new F<V4<A>, Stream<A>>() {
    public Stream<A> f(final V4<A> v) {
      return v.toStream();
    }
  };
}
 
开发者ID:JayTheDonkey,项目名称:rpg.java,代码行数:13,代码来源:V4.java


示例12: toStream

import fj.data.Stream; //导入依赖的package包/类
/**
 * Returns a stream of the elements of this vector.
 *
 * @return a stream of the elements of this vector.
 */
public Stream<A> toStream() {
  return Stream.cons(head._1(), new P1<Stream<A>>() {
    public Stream<A> _1() {
      return tail.toStream();
    }
  });
}
 
开发者ID:JayTheDonkey,项目名称:rpg.java,代码行数:13,代码来源:V4.java


示例13: element

import fj.data.Stream; //导入依赖的package包/类
/**
   * Returns a parser that produces an element from the stream if it is available and fails otherwise.
   *
   * @param e The error to fail with if no element is available.
   * @return A parser that produces an element from the stream if it is available and fails otherwise.
   */
  public static <I, E> Parser<Stream<I>, I, E> element(final P1<E> e) {
    return parser(new F<Stream<I>, Validation<E, Result<Stream<I>, I>>>() {
      @Override
public Validation<E, Result<Stream<I>, I>> f(final Stream<I> is) {
        return is.isEmpty() ?
            Validation.<E, Result<Stream<I>, I>>fail(e._1()) :
            Validation.<E, Result<Stream<I>, I>>success(result(is.tail()._1(), is.head()));
      }
    });
  }
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:17,代码来源:Parser.java


示例14: character

import fj.data.Stream; //导入依赖的package包/类
/**
   * Returns a parser that produces the given character or fails otherwise.
   *
   * @param missing The error if no character is available.
   * @param sat     The error if the produced character is not the one given.
   * @param c       The character to produce in the parser.
   * @return A parser that produces the given character or fails otherwise.
   */
  public static <E> Parser<Stream<Character>, Character, E> character(final P1<E> missing, final F<Character, E> sat,
                                                                      final char c) {
    return StreamParser.satisfy(missing, sat, new F<Character, Boolean>() {
      @Override
public Boolean f(final Character x) {
        return x == c;
      }
    });
  }
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:18,代码来源:Parser.java


示例15: streamOrd

import fj.data.Stream; //导入依赖的package包/类
/**
 * An order instance for the {@link Stream} type.
 *
 * @param oa Order across the elements of the stream.
 * @return An order instance for the {@link Stream} type.
 */
public static <A> Ord<Stream<A>> streamOrd(final Ord<A> oa) {
  return ord(s1 -> s2 -> {
      if (s1.isEmpty())
          return s2.isEmpty() ? Ordering.EQ : Ordering.LT;
      else if (s2.isEmpty())
          return s1.isEmpty() ? Ordering.EQ : Ordering.GT;
      else {
          final Ordering c = oa.compare(s1.head(), s2.head());
          return c == Ordering.EQ ? streamOrd(oa).f.f(s1.tail()._1()).f(s2.tail()._1()) : c;
      }
  });
}
 
开发者ID:JayTheDonkey,项目名称:rpg.java,代码行数:19,代码来源:Ord.java


示例16: upper

import fj.data.Stream; //导入依赖的package包/类
/**
   * Returns a parser that produces a upper-case character.
   *
   * @param missing The error if there is no character on the stream to produce a upper-case character with.
   * @param sat     The error if the produced character is not a upper-case character.
   * @return A parser that produces a upper-case character.
   * @see Character#isUpperCase(char)
   */
  public static <E> Parser<Stream<Character>, Character, E> upper(final P1<E> missing, final F<Character, E> sat) {
    return StreamParser.satisfy(missing, sat, new F<Character, Boolean>() {
      @Override
public Boolean f(final Character c) {
        return Character.isUpperCase(c);
      }
    });
  }
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:17,代码来源:Parser.java


示例17: defined

import fj.data.Stream; //导入依赖的package包/类
/**
   * Returns a parser that produces a defined character.
   *
   * @param missing The error if there is no character on the stream to produce a defined character with.
   * @param sat     The error if the produced character is not a defined character.
   * @return A parser that produces a defined character.
   * @see Character#isDefined(char)
   */
  public static <E> Parser<Stream<Character>, Character, E> defined(final P1<E> missing, final F<Character, E> sat) {
    return StreamParser.satisfy(missing, sat, new F<Character, Boolean>() {
      @Override
public Boolean f(final Character c) {
        return Character.isDefined(c);
      }
    });
  }
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:17,代码来源:Parser.java


示例18: identifierIgnorable

import fj.data.Stream; //导入依赖的package包/类
/**
   * Returns a parser that produces an identifier-ignorable character.
   *
   * @param missing The error if there is no character on the stream to produce an identifier-ignorable character with.
   * @param sat     The error if the produced character is not an identifier-ignorable character.
   * @return A parser that produces an identifier-ignorable character.
   * @see Character#isIdentifierIgnorable(char)
   */
  public static <E> Parser<Stream<Character>, Character, E> identifierIgnorable(final P1<E> missing,
                                                                                final F<Character, E> sat) {
    return StreamParser.satisfy(missing, sat, new F<Character, Boolean>() {
      @Override
public Boolean f(final Character c) {
        return Character.isIdentifierIgnorable(c);
      }
    });
  }
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:18,代码来源:Parser.java


示例19: toStream_

import fj.data.Stream; //导入依赖的package包/类
/**
 * Returns a function that transforms a vector-8 to a stream of its elements.
 *
 * @return a function that transforms a vector-8 to a stream of its elements.
 */
public static <A> F<V8<A>, Stream<A>> toStream_() {
  return new F<V8<A>, Stream<A>>() {
    public Stream<A> f(final V8<A> v) {
      return v.toStream();
    }
  };
}
 
开发者ID:JayTheDonkey,项目名称:rpg.java,代码行数:13,代码来源:V8.java


示例20: isoControl

import fj.data.Stream; //导入依赖的package包/类
/**
   * Returns a parser that produces an ISO control character.
   *
   * @param missing The error if there is no character on the stream to produce an ISO control character with.
   * @param sat     The error if the produced character is not an ISO control character.
   * @return A parser that produces an ISO control character.
   * @see Character#isISOControl(char)
   */
  public static <E> Parser<Stream<Character>, Character, E> isoControl(final P1<E> missing,
                                                                       final F<Character, E> sat) {
    return StreamParser.satisfy(missing, sat, new F<Character, Boolean>() {
      @Override
public Boolean f(final Character c) {
        return Character.isISOControl(c);
      }
    });
  }
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:18,代码来源:Parser.java



注:本文中的fj.data.Stream类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PasswordEncoder类代码示例发布时间:2022-05-23
下一篇:
Java LocaleUtils类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap