本文整理匯總了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);
}