akka.protobuf.ByteString.balancedConcat()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(4.2k)|赞(0)|评价(0)|浏览(116)

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

ByteString.balancedConcat介绍

暂无

代码示例

代码示例来源:origin: com.typesafe.akka/akka-protobuf_2.12

private static ByteString balancedConcat(Iterator<ByteString> iterator,
  int length) {
 assert length >= 1;
 ByteString result;
 if (length == 1) {
  result = iterator.next();
 } else {
  int halfLength = length >>> 1;
  ByteString left = balancedConcat(iterator, halfLength);
  ByteString right = balancedConcat(iterator, length - halfLength);
  result = left.concat(right);
 }
 return result;
}

代码示例来源:origin: com.typesafe.akka/akka-protobuf_2.11

private static ByteString balancedConcat(Iterator<ByteString> iterator,
  int length) {
 assert length >= 1;
 ByteString result;
 if (length == 1) {
  result = iterator.next();
 } else {
  int halfLength = length >>> 1;
  ByteString left = balancedConcat(iterator, halfLength);
  ByteString right = balancedConcat(iterator, length - halfLength);
  result = left.concat(right);
 }
 return result;
}

代码示例来源:origin: com.typesafe.akka/akka-protobuf

private static ByteString balancedConcat(Iterator<ByteString> iterator,
  int length) {
 assert length >= 1;
 ByteString result;
 if (length == 1) {
  result = iterator.next();
 } else {
  int halfLength = length >>> 1;
  ByteString left = balancedConcat(iterator, halfLength);
  ByteString right = balancedConcat(iterator, length - halfLength);
  result = left.concat(right);
 }
 return result;
}

代码示例来源:origin: com.typesafe.akka/akka-protobuf_2.11

/**
 * Concatenates all byte strings in the iterable and returns the result.
 * This is designed to run in O(list size), not O(total bytes).
 *
 * <p>The returned {@code ByteString} is not necessarily a unique object.
 * If the list is empty, the returned object is the singleton empty
 * {@code ByteString}.  If the list has only one element, that
 * {@code ByteString} will be returned without copying.
 *
 * @param byteStrings strings to be concatenated
 * @return new {@code ByteString}
 */
public static ByteString copyFrom(Iterable<ByteString> byteStrings) {
 Collection<ByteString> collection;
 if (!(byteStrings instanceof Collection)) {
  collection = new ArrayList<ByteString>();
  for (ByteString byteString : byteStrings) {
   collection.add(byteString);
  }
 } else {
  collection = (Collection<ByteString>) byteStrings;
 }
 ByteString result;
 if (collection.isEmpty()) {
  result = EMPTY;
 } else {
  result = balancedConcat(collection.iterator(), collection.size());
 }
 return result;
}

代码示例来源:origin: com.typesafe.akka/akka-protobuf_2.12

/**
 * Concatenates all byte strings in the iterable and returns the result.
 * This is designed to run in O(list size), not O(total bytes).
 *
 * <p>The returned {@code ByteString} is not necessarily a unique object.
 * If the list is empty, the returned object is the singleton empty
 * {@code ByteString}.  If the list has only one element, that
 * {@code ByteString} will be returned without copying.
 *
 * @param byteStrings strings to be concatenated
 * @return new {@code ByteString}
 */
public static ByteString copyFrom(Iterable<ByteString> byteStrings) {
 Collection<ByteString> collection;
 if (!(byteStrings instanceof Collection)) {
  collection = new ArrayList<ByteString>();
  for (ByteString byteString : byteStrings) {
   collection.add(byteString);
  }
 } else {
  collection = (Collection<ByteString>) byteStrings;
 }
 ByteString result;
 if (collection.isEmpty()) {
  result = EMPTY;
 } else {
  result = balancedConcat(collection.iterator(), collection.size());
 }
 return result;
}

代码示例来源:origin: com.typesafe.akka/akka-protobuf

/**
 * Concatenates all byte strings in the iterable and returns the result.
 * This is designed to run in O(list size), not O(total bytes).
 *
 * <p>The returned {@code ByteString} is not necessarily a unique object.
 * If the list is empty, the returned object is the singleton empty
 * {@code ByteString}.  If the list has only one element, that
 * {@code ByteString} will be returned without copying.
 *
 * @param byteStrings strings to be concatenated
 * @return new {@code ByteString}
 */
public static ByteString copyFrom(Iterable<ByteString> byteStrings) {
 Collection<ByteString> collection;
 if (!(byteStrings instanceof Collection)) {
  collection = new ArrayList<ByteString>();
  for (ByteString byteString : byteStrings) {
   collection.add(byteString);
  }
 } else {
  collection = (Collection<ByteString>) byteStrings;
 }
 ByteString result;
 if (collection.isEmpty()) {
  result = EMPTY;
 } else {
  result = balancedConcat(collection.iterator(), collection.size());
 }
 return result;
}

相关文章