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


Java Iterators.forArray方法代码示例

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


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

示例1: chunkify

import com.google.common.collect.Iterators; //导入方法依赖的package包/类
/**
 * Chunkify strings to a set length, but do not break words
 *
 * @param string The string to chunkify
 * @param length The max length of the chunks
 * @return A list containing the resulting chunks
 */
public static List<String> chunkify(String string, int length) {
  List<String> chunks = new ArrayList<>();

  if (StringUtils.isEmpty(string) || string.length() <= length) {
    chunks.add(string);
    return chunks;
  }

  Iterator<String> words = Iterators.forArray(string.split(" "));
  int chunkCount = (int) Math.ceil(((double) string.length()) / length);

  IntStream.rangeClosed(1, chunkCount).forEach(ci -> {
    StringBuilder newChunk = new StringBuilder();

    while (newChunk.length() < length) {
      if (!words.hasNext()) break;
      newChunk.append(" ").append(words.next());
    }

    if (StringUtils.isNotEmpty(newChunk)) chunks.add(newChunk.toString().trim());
  });

  return chunks;
}
 
开发者ID:Juraji,项目名称:Biliomi,代码行数:32,代码来源:TextUtils.java

示例2: serverStarting

import com.google.common.collect.Iterators; //导入方法依赖的package包/类
@EventHandler
public void serverStarting(FMLServerStartingEvent event) {
    Iterator<CommandModule> modules = Iterators.forArray(
            new RegionCommands(),
            new OperationCommands(),
            new SessionCommands());
    modules.forEachRemaining(m -> m.addCommands(event::registerServerCommand));
}
 
开发者ID:kenzierocks,项目名称:HardVox,代码行数:9,代码来源:HardVox.java

示例3: run

import com.google.common.collect.Iterators; //导入方法依赖的package包/类
private void run(String[] args) throws Exception {
  if (args.length < 1 || args.length > 3) {
    System.out.println("Usage: command [-k] <main_dex_list> [<proguard_map>]");
    System.exit(0);
  }

  Iterator<String> arguments = Iterators.forArray(args);
  Function<String, String> outputGenerator;
  String arg = arguments.next();
  if (arg.equals("-k")) {
    outputGenerator = this::toKeepRule;
    arg = arguments.next();
  } else {
    outputGenerator = this::toClassFilePath;
  }
  Path mainDexList = Paths.get(arg);

  final ClassNameMapper mapper =
      arguments.hasNext() ? ProguardMapReader.mapperFromFile(Paths.get(arguments.next())) : null;

  FileUtils.readTextFile(mainDexList)
      .stream()
      .map(this::stripDotClass)
      .map(name -> name.replace('/', '.'))
      .map(name -> deobfuscateClassName(name, mapper))
      .map(outputGenerator)
      .sorted()
      .collect(Collectors.toList())
      .forEach(System.out::println);
}
 
开发者ID:inferjay,项目名称:r8,代码行数:31,代码来源:ReadMainDexList.java

示例4: getConfig

import com.google.common.collect.Iterators; //导入方法依赖的package包/类
/**
 * Creates a {@link FolderConfiguration} matching the folder segments.
 * @param folderSegments The segments of the folder name. The first segments should contain
 * the name of the folder
 * @return a FolderConfiguration object, or null if the folder name isn't valid..
 */
@Nullable
public static FolderConfiguration getConfig(@NonNull String[] folderSegments) {
    Iterator<String> iterator = Iterators.forArray(folderSegments);
    if (iterator.hasNext()) {
        // Skip the first segment: it should be just the base folder, such as "values" or
        // "layout"
        iterator.next();
    }

    return getConfigFromQualifiers(iterator);
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:18,代码来源:FolderConfiguration.java

示例5: childrenIterator

import com.google.common.collect.Iterators; //导入方法依赖的package包/类
@Override
public Iterator<Tree> childrenIterator() {
  return Iterators.forArray(value, unit);
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:5,代码来源:DimensionTreeImpl.java

示例6: iterator

import com.google.common.collect.Iterators; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public Iterator<T> iterator() {
    return Iterators.forArray((T[])arr);
}
 
开发者ID:CvvT,项目名称:andbg,代码行数:6,代码来源:ArraySortedSet.java

示例7: iterator

import com.google.common.collect.Iterators; //导入方法依赖的package包/类
@Override
public Iterator<String> iterator() {
  return isEmpty()
      ? Collections.<String>emptyIterator()
      : Iterators.forArray(vars);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:Generics.java

示例8: childrenIterator

import com.google.common.collect.Iterators; //导入方法依赖的package包/类
@Override
public Iterator<Tree> childrenIterator() {
  return Iterators.forArray(variable, colon, value, semicolon);
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:5,代码来源:ScssVariableDeclarationTreeImpl.java

示例9: iterator

import com.google.common.collect.Iterators; //导入方法依赖的package包/类
@Override
public Iterator<BulkItemResponse> iterator() {
    return Iterators.forArray(responses);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:5,代码来源:BulkResponse.java

示例10: childrenIterator

import com.google.common.collect.Iterators; //导入方法依赖的package包/类
@Override
public Iterator<Tree> childrenIterator() {
  return Iterators.forArray(key, colon, value);
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:5,代码来源:ScssMapEntryTreeImpl.java

示例11: childrenIterator

import com.google.common.collect.Iterators; //导入方法依赖的package包/类
@Override
public Iterator<Tree> childrenIterator() {
  return Iterators.forArray(directive, parameters, ruleset, block);
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:5,代码来源:ScssAtRootTreeImpl.java

示例12: iterator

import com.google.common.collect.Iterators; //导入方法依赖的package包/类
@Override
public Iterator<PhysicalOperator> iterator() {
  return Iterators.forArray(left, right);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:5,代码来源:NestedLoopJoinPOP.java

示例13: childrenIterator

import com.google.common.collect.Iterators; //导入方法依赖的package包/类
@Override
public Iterator<Tree> childrenIterator() {
  return Iterators.forArray(prefix, name);
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:5,代码来源:ScssVariableTreeImpl.java

示例14: childrenIterator

import com.google.common.collect.Iterators; //导入方法依赖的package包/类
@Override
public Iterator<Tree> childrenIterator() {
  return Iterators.forArray(property, lessMerge);
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:5,代码来源:PropertyTreeImpl.java

示例15: iterator

import com.google.common.collect.Iterators; //导入方法依赖的package包/类
@Override
public Iterator<PhysicalOperator> iterator() {
    return Iterators.forArray(left, right);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:5,代码来源:HashJoinPOP.java


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