當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。