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