io.vavr.collection.HashSet.length()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(3.2k)|赞(0)|评价(0)|浏览(137)

本文整理了Java中io.vavr.collection.HashSet.length()方法的一些代码示例,展示了HashSet.length()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HashSet.length()方法的具体详情如下:
包路径:io.vavr.collection.HashSet
类名称:HashSet
方法名:length

HashSet.length介绍

暂无

代码示例

代码示例来源:origin: vavr-io/vavr

@Override
public HashSet<T> dropWhile(Predicate<? super T> predicate) {
  Objects.requireNonNull(predicate, "predicate is null");
  final HashSet<T> dropped = HashSet.ofAll(iterator().dropWhile(predicate));
  return dropped.length() == length() ? this : dropped;
}

代码示例来源:origin: vavr-io/vavr

@Override
public HashSet<T> takeWhile(Predicate<? super T> predicate) {
  Objects.requireNonNull(predicate, "predicate is null");
  final HashSet<T> taken = HashSet.ofAll(iterator().takeWhile(predicate));
  return taken.length() == length() ? this : taken;
}

代码示例来源:origin: vavr-io/vavr

@Override
public HashSet<T> filter(Predicate<? super T> predicate) {
  Objects.requireNonNull(predicate, "predicate is null");
  final HashSet<T> filtered = HashSet.ofAll(iterator().filter(predicate));
  if (filtered.isEmpty()) {
    return empty();
  } else if (filtered.length() == length()) {
    return this;
  } else {
    return filtered;
  }
}

代码示例来源:origin: io.vavr/vavr

@Override
public HashSet<T> dropWhile(Predicate<? super T> predicate) {
  Objects.requireNonNull(predicate, "predicate is null");
  final HashSet<T> dropped = HashSet.ofAll(iterator().dropWhile(predicate));
  return dropped.length() == length() ? this : dropped;
}

代码示例来源:origin: io.vavr/vavr

@Override
public HashSet<T> takeWhile(Predicate<? super T> predicate) {
  Objects.requireNonNull(predicate, "predicate is null");
  final HashSet<T> taken = HashSet.ofAll(iterator().takeWhile(predicate));
  return taken.length() == length() ? this : taken;
}

代码示例来源:origin: io.vavr/vavr

@Override
public HashSet<T> filter(Predicate<? super T> predicate) {
  Objects.requireNonNull(predicate, "predicate is null");
  final HashSet<T> filtered = HashSet.ofAll(iterator().filter(predicate));
  if (filtered.isEmpty()) {
    return empty();
  } else if (filtered.length() == length()) {
    return this;
  } else {
    return filtered;
  }
}

代码示例来源:origin: vavr-io/vavr-jackson

@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);
}

代码示例来源:origin: vavr-io/vavr-jackson

@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");
}

相关文章