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


Java IntMath.saturatedAdd方法代码示例

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


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

示例1: degree

import com.google.common.math.IntMath; //导入方法依赖的package包/类
@Override
public int degree(N node) {
  if (isDirected()) {
    return IntMath.saturatedAdd(predecessors(node).size(), successors(node).size());
  } else {
    Set<N> neighbors = adjacentNodes(node);
    int selfLoopCount = (allowsSelfLoops() && neighbors.contains(node)) ? 1 : 0;
    return IntMath.saturatedAdd(neighbors.size(), selfLoopCount);
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:11,代码来源:AbstractBaseGraph.java

示例2: degree

import com.google.common.math.IntMath; //导入方法依赖的package包/类
@Override
public int degree(N node) {
  if (isDirected()) {
    return IntMath.saturatedAdd(inEdges(node).size(), outEdges(node).size());
  } else {
    return IntMath.saturatedAdd(incidentEdges(node).size(), edgesConnecting(node, node).size());
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:9,代码来源:AbstractNetwork.java

示例3: degree

import com.google.common.math.IntMath; //导入方法依赖的package包/类
@Override
public int degree(Object node) {
  if (isDirected()) {
    return IntMath.saturatedAdd(predecessors(node).size(), successors(node).size());
  } else {
    Set<N> neighbors = adjacentNodes(node);
    int selfLoopCount = (allowsSelfLoops() && neighbors.contains(node)) ? 1 : 0;
    return IntMath.saturatedAdd(neighbors.size(), selfLoopCount);
  }
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:11,代码来源:AbstractBaseGraph.java

示例4: degree

import com.google.common.math.IntMath; //导入方法依赖的package包/类
@Override
public int degree(Object node) {
  if (isDirected()) {
    return IntMath.saturatedAdd(inEdges(node).size(), outEdges(node).size());
  } else {
    return IntMath.saturatedAdd(incidentEdges(node).size(), edgesConnecting(node, node).size());
  }
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:9,代码来源:AbstractNetwork.java

示例5: union

import com.google.common.math.IntMath; //导入方法依赖的package包/类
/**
 * Returns an unmodifiable <b>view</b> of the union of two sets. The returned
 * set contains all elements that are contained in either backing set.
 * Iterating over the returned set iterates first over all the elements of
 * {@code set1}, then over each element of {@code set2}, in order, that is not
 * contained in {@code set1}.
 *
 * <p>Results are undefined if {@code set1} and {@code set2} are sets based on
 * different equivalence relations (as {@link HashSet}, {@link TreeSet}, and
 * the {@link Map#keySet} of an {@code IdentityHashMap} all are).
 */
public static <E> SetView<E> union(final Set<? extends E> set1, final Set<? extends E> set2) {
  checkNotNull(set1, "set1");
  checkNotNull(set2, "set2");

  final Set<? extends E> set2minus1 = difference(set2, set1);

  return new SetView<E>() {
    @Override
    public int size() {
      return IntMath.saturatedAdd(set1.size(), set2minus1.size());
    }

    @Override
    public boolean isEmpty() {
      return set1.isEmpty() && set2.isEmpty();
    }

    @Override
    public UnmodifiableIterator<E> iterator() {
      return Iterators.unmodifiableIterator(
          Iterators.concat(set1.iterator(), set2minus1.iterator()));
    }

    @Override
    public Stream<E> stream() {
      return Stream.concat(set1.stream(), set2minus1.stream());
    }

    @Override
    public Stream<E> parallelStream() {
      return Stream.concat(set1.parallelStream(), set2minus1.parallelStream());
    }

    @Override
    public boolean contains(Object object) {
      return set1.contains(object) || set2.contains(object);
    }

    @Override
    public <S extends Set<E>> S copyInto(S set) {
      set.addAll(set1);
      set.addAll(set2);
      return set;
    }

    @Override
    public ImmutableSet<E> immutableCopy() {
      return new ImmutableSet.Builder<E>().addAll(set1).addAll(set2).build();
    }
  };
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:63,代码来源:Sets.java

示例6: size

import com.google.common.math.IntMath; //导入方法依赖的package包/类
@Override
public int size() {
  return IntMath.saturatedAdd(rest.length, 1);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:5,代码来源:Lists.java

示例7: union

import com.google.common.math.IntMath; //导入方法依赖的package包/类
/**
 * Returns an unmodifiable <b>view</b> of the union of two sets. The returned
 * set contains all elements that are contained in either backing set.
 * Iterating over the returned set iterates first over all the elements of
 * {@code set1}, then over each element of {@code set2}, in order, that is not
 * contained in {@code set1}.
 *
 * <p>Results are undefined if {@code set1} and {@code set2} are sets based on
 * different equivalence relations (as {@link HashSet}, {@link TreeSet}, and
 * the {@link Map#keySet} of an {@code IdentityHashMap} all are).
 */


public static <E> SetView<E> union(
  final Set<? extends E> set1, final Set<? extends E> set2) {
  checkNotNull(set1, "set1");
  checkNotNull(set2, "set2");
  final Set<? extends E> set2minus1 = difference(set2, set1);
  return new SetView<E>() {
    @Override
    public int size() {
      return IntMath.saturatedAdd(set1.size(), set2minus1.size());
    }

    @Override
    public boolean isEmpty() {
      return set1.isEmpty() && set2.isEmpty();
    }

    @Override
    public Iterator<E> iterator() {
      return Iterators.unmodifiableIterator(Iterators.concat(set1.iterator(), set2minus1.iterator()));
    }

    @Override
    public boolean contains(Object object) {
      return set1.contains(object) || set2.contains(object);
    }

    @Override
    public <S extends Set<E>> S copyInto(S set) {
      set.addAll(set1);
      set.addAll(set2);
      return set;
    }

    @Override
    public ImmutableSet<E> immutableCopy() {
      return new ImmutableSet.Builder<E>().addAll(set1).addAll(set2).build();
    }
  };
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:53,代码来源:Sets.java

示例8: union

import com.google.common.math.IntMath; //导入方法依赖的package包/类
/**
 * Returns an unmodifiable <b>view</b> of the union of two sets. The returned
 * set contains all elements that are contained in either backing set.
 * Iterating over the returned set iterates first over all the elements of
 * {@code set1}, then over each element of {@code set2}, in order, that is not
 * contained in {@code set1}.
 *
 * <p>Results are undefined if {@code set1} and {@code set2} are sets based on
 * different equivalence relations (as {@link HashSet}, {@link TreeSet}, and
 * the {@link Map#keySet} of an {@code IdentityHashMap} all are).
 */
public static <E> SetView<E> union(final Set<? extends E> set1, final Set<? extends E> set2) {
  checkNotNull(set1, "set1");
  checkNotNull(set2, "set2");

  final Set<? extends E> set2minus1 = difference(set2, set1);

  return new SetView<E>() {
    @Override
    public int size() {
      return IntMath.saturatedAdd(set1.size(), set2minus1.size());
    }

    @Override
    public boolean isEmpty() {
      return set1.isEmpty() && set2.isEmpty();
    }

    @Override
    public Iterator<E> iterator() {
      return Iterators.unmodifiableIterator(
          Iterators.concat(set1.iterator(), set2minus1.iterator()));
    }

    @Override
    public boolean contains(Object object) {
      return set1.contains(object) || set2.contains(object);
    }

    @Override
    public <S extends Set<E>> S copyInto(S set) {
      set.addAll(set1);
      set.addAll(set2);
      return set;
    }

    @Override
    public ImmutableSet<E> immutableCopy() {
      return new ImmutableSet.Builder<E>().addAll(set1).addAll(set2).build();
    }
  };
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:53,代码来源:Sets.java


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