当前位置: 首页>>代码示例>>Java>>正文


Java HashSet.of方法代码示例

本文整理汇总了Java中io.vavr.collection.HashSet.of方法的典型用法代码示例。如果您正苦于以下问题:Java HashSet.of方法的具体用法?Java HashSet.of怎么用?Java HashSet.of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.vavr.collection.HashSet的用法示例。


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

示例1: tailRec

import io.vavr.collection.HashSet; //导入方法依赖的package包/类
public static  <T,R> HashSet<R> tailRec(T initial, Function<? super T, ? extends HashSet<? extends io.vavr.control.Either<T, R>>> fn) {
    HashSet<io.vavr.control.Either<T, R>> next = HashSet.of(io.vavr.control.Either.left(initial));

    boolean newValue[] = {true};
    for(;;){

        next = next.flatMap(e -> e.fold(s -> {
                    newValue[0]=true;
                    return fn.apply(s); },
                p -> {
                    newValue[0]=false;
                    return HashSet.of(e);
                }));
        if(!newValue[0])
            break;

    }

    return next.filter(io.vavr.control.Either::isRight).map(io.vavr.control.Either::get);
}
 
开发者ID:aol,项目名称:cyclops,代码行数:21,代码来源:HashSets.java

示例2: tailRecEither

import io.vavr.collection.HashSet; //导入方法依赖的package包/类
public static  <T,R> HashSet<R> tailRecEither(T initial, Function<? super T, ? extends HashSet<? extends Either<T, R>>> fn) {
    HashSet<Either<T, R>> next = HashSet.of(Either.left(initial));

    boolean newValue[] = {true};
    for(;;){

        next = next.flatMap(e -> e.visit(s -> {
                    newValue[0]=true;
                    return fn.apply(s); },
                p -> {
                    newValue[0]=false;
                    return HashSet.of(e);
                }));
        if(!newValue[0])
            break;

    }

    return next.filter(Either::isRight).map(e->e.orElse(null));
}
 
开发者ID:aol,项目名称:cyclops,代码行数:21,代码来源:HashSets.java

示例3: setUp

import io.vavr.collection.HashSet; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
  // logger.info(logger.getName());
  logger.debug(" ===========> debug log");
  logger.info(" *** ");
  tickers = HashSet.of(Ticker.of("ABC.L"), Ticker.of("DEF.L"));
}
 
开发者ID:the-james-burton,项目名称:the-turbine,代码行数:8,代码来源:TurbineControllerTest.java

示例4: testHashSet

import io.vavr.collection.HashSet; //导入方法依赖的package包/类
@Test
public void testHashSet() throws Exception {
    HashSet<A> src = HashSet.of(new B("a", "b"));
    String json = MAPPER.writeValueAsString(new HashSetPojo().setValue(src));
    Assert.assertEquals(json, "{\"value\":[{\"ExtFieldsPojoTest$B\":{\"a\":\"a\",\"b\":\"b\"}}]}");
    HashSetPojo pojo = MAPPER.readValue(json, HashSetPojo.class);
    HashSet<A> restored = pojo.getValue();
    Assert.assertEquals(restored.filter(e -> e instanceof B).length(), 1);
    Assert.assertEquals(restored.head().a, "a");
    Assert.assertEquals(((B) restored.head()).b, "b");
}
 
开发者ID:vavr-io,项目名称:vavr-jackson,代码行数:12,代码来源:ExtFieldsPojoTest.java

示例5: testHashSetOfString

import io.vavr.collection.HashSet; //导入方法依赖的package包/类
@Test
public void testHashSetOfString() throws Exception {
    String src0 = "A";
    String src1 = "B";
    String src2 = "C";
    HashSet<String> src = HashSet.of(src0, src1, src2);
    String json = MAPPER.writeValueAsString(new ParameterizedHashSetPojo<>(src));
    Assert.assertEquals(json, "{\"value\":[\"A\",\"B\",\"C\"]}");
    ParameterizedHashSetPojo<java.lang.String> restored = 
            MAPPER.readValue(json, new TypeReference<ParameterizedHashSetPojo<java.lang.String>>(){});
    Assert.assertEquals(src, restored.getValue());
}
 
开发者ID:vavr-io,项目名称:vavr-jackson,代码行数:13,代码来源:ParameterizedPojoTest.java

示例6: testHashSetOfTuple

import io.vavr.collection.HashSet; //导入方法依赖的package包/类
@Test
public void testHashSetOfTuple() throws Exception {
    String src00 = "A";
    String src01 = "B";
    Tuple2<String, String> src0 = Tuple.of(src00, src01);
    HashSet<Tuple2<String, String>> src = HashSet.of(src0);
    String json = MAPPER.writeValueAsString(new ParameterizedHashSetPojo<>(src));
    Assert.assertEquals(json, "{\"value\":[[\"A\",\"B\"]]}");
    ParameterizedHashSetPojo<io.vavr.Tuple2<java.lang.String, java.lang.String>> restored = 
            MAPPER.readValue(json, new TypeReference<ParameterizedHashSetPojo<io.vavr.Tuple2<java.lang.String, java.lang.String>>>(){});
    Assert.assertEquals(src, restored.getValue());
}
 
开发者ID:vavr-io,项目名称:vavr-jackson,代码行数:13,代码来源:ParameterizedPojoTest.java

示例7: testHashSetOfString

import io.vavr.collection.HashSet; //导入方法依赖的package包/类
@Test
public void testHashSetOfString() throws Exception {
    String src0 = "A";
    String src1 = "B";
    String src2 = "C";
    HashSet<String> src = HashSet.of(src0, src1, src2);
    String json = MAPPER.writeValueAsString(new HashSetOfString().setValue(src));
    Assert.assertEquals(json, "{\"value\":[\"A\",\"B\",\"C\"]}");
    HashSetOfString restored = MAPPER.readValue(json, HashSetOfString.class);
    Assert.assertEquals(src, restored.getValue());
}
 
开发者ID:vavr-io,项目名称:vavr-jackson,代码行数:12,代码来源:SimplePojoTest.java

示例8: testHashSetOfTuple

import io.vavr.collection.HashSet; //导入方法依赖的package包/类
@Test
public void testHashSetOfTuple() throws Exception {
    String src00 = "A";
    String src01 = "B";
    Tuple2<String, String> src0 = Tuple.of(src00, src01);
    HashSet<Tuple2<String, String>> src = HashSet.of(src0);
    String json = MAPPER.writeValueAsString(new HashSetOfTuple().setValue(src));
    Assert.assertEquals(json, "{\"value\":[[\"A\",\"B\"]]}");
    HashSetOfTuple restored = MAPPER.readValue(json, HashSetOfTuple.class);
    Assert.assertEquals(src, restored.getValue());
}
 
开发者ID:vavr-io,项目名称:vavr-jackson,代码行数:12,代码来源:SimplePojoTest.java

示例9: testHashSet

import io.vavr.collection.HashSet; //导入方法依赖的package包/类
@Test
public void testHashSet() throws Exception {
    HashSet<I> src = HashSet.of(new B());
    String json = MAPPER.writeValueAsString(new HashSetPojo().setValue(src));
    Assert.assertEquals(json, "{\"value\":[{\"type\":\"b\"}]}");
    HashSetPojo pojo = MAPPER.readValue(json, HashSetPojo.class);
    HashSet<I> restored = pojo.getValue();
    Assert.assertEquals(restored.filter(e -> e instanceof B).length(), 1);
}
 
开发者ID:vavr-io,项目名称:vavr-jackson,代码行数:10,代码来源:PolymorphicPojoTest.java

示例10: anySubTag

import io.vavr.collection.HashSet; //导入方法依赖的package包/类
/**
 * Matches a tag or (grant)child tag with the given name(s), emitting all tha events that make up that tag and its content.
 */
public static SelectedSubTagProtocol anySubTag(QName... names) {
    return new SelectedSubTagProtocol(HashSet.of(names));
}
 
开发者ID:Tradeshift,项目名称:ts-reaktive,代码行数:7,代码来源:XMLProtocol.java


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