本文整理汇总了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;
}
示例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));
}
示例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);
}
示例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);
}
示例5: childrenIterator
import com.google.common.collect.Iterators; //导入方法依赖的package包/类
@Override
public Iterator<Tree> childrenIterator() {
return Iterators.forArray(value, unit);
}
示例6: iterator
import com.google.common.collect.Iterators; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public Iterator<T> iterator() {
return Iterators.forArray((T[])arr);
}
示例7: iterator
import com.google.common.collect.Iterators; //导入方法依赖的package包/类
@Override
public Iterator<String> iterator() {
return isEmpty()
? Collections.<String>emptyIterator()
: Iterators.forArray(vars);
}
示例8: childrenIterator
import com.google.common.collect.Iterators; //导入方法依赖的package包/类
@Override
public Iterator<Tree> childrenIterator() {
return Iterators.forArray(variable, colon, value, semicolon);
}
示例9: iterator
import com.google.common.collect.Iterators; //导入方法依赖的package包/类
@Override
public Iterator<BulkItemResponse> iterator() {
return Iterators.forArray(responses);
}
示例10: childrenIterator
import com.google.common.collect.Iterators; //导入方法依赖的package包/类
@Override
public Iterator<Tree> childrenIterator() {
return Iterators.forArray(key, colon, value);
}
示例11: childrenIterator
import com.google.common.collect.Iterators; //导入方法依赖的package包/类
@Override
public Iterator<Tree> childrenIterator() {
return Iterators.forArray(directive, parameters, ruleset, block);
}
示例12: iterator
import com.google.common.collect.Iterators; //导入方法依赖的package包/类
@Override
public Iterator<PhysicalOperator> iterator() {
return Iterators.forArray(left, right);
}
示例13: childrenIterator
import com.google.common.collect.Iterators; //导入方法依赖的package包/类
@Override
public Iterator<Tree> childrenIterator() {
return Iterators.forArray(prefix, name);
}
示例14: childrenIterator
import com.google.common.collect.Iterators; //导入方法依赖的package包/类
@Override
public Iterator<Tree> childrenIterator() {
return Iterators.forArray(property, lessMerge);
}
示例15: iterator
import com.google.common.collect.Iterators; //导入方法依赖的package包/类
@Override
public Iterator<PhysicalOperator> iterator() {
return Iterators.forArray(left, right);
}