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


Java Iterators类代码示例

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


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

示例1: iterator

import com.google.common.collect.Iterators; //导入依赖的package包/类
@Override
public Iterator<String[]> iterator() throws Exception{
    Iterator<CSVRecord> iterCSVRecords = this.getCSVParser().iterator();
    
    Iterator<String[]> iterStringArrays = Iterators.transform(iterCSVRecords, (CSVRecord input) -> {
        Iterator<String> iterCols = input.iterator();
        
        List<String> cols = new ArrayList();
        while(iterCols.hasNext()){
            cols.add(iterCols.next());
        }
        
        String[] output = cols.toArray(new String[0]);
        
        return output;
    });
    
    return iterStringArrays;
}
 
开发者ID:frictionlessdata,项目名称:tableschema-java,代码行数:20,代码来源:CsvDataSource.java

示例2: getFields

import com.google.common.collect.Iterators; //导入依赖的package包/类
@Nonnull @Override public Set<? extends Field> getFields() {
    return new AbstractSet<Field>() {
        @Nonnull @Override public Iterator<Field> iterator() {
            return Iterators.transform(Iterators.forArray(cls.getDeclaredFields()),
                    new Function<java.lang.reflect.Field, Field>() {
                        @Nullable @Override public Field apply(@Nullable java.lang.reflect.Field input) {
                            return new ReflectionField(input);
                        }
                    });
        }

        @Override public int size() {
            return cls.getDeclaredFields().length;
        }
    };
}
 
开发者ID:CvvT,项目名称:andbg,代码行数:17,代码来源:ReflectionClassDef.java

示例3: ExternalSortBatch

import com.google.common.collect.Iterators; //导入依赖的package包/类
public ExternalSortBatch(ExternalSort popConfig, FragmentContext context, RecordBatch incoming) throws OutOfMemoryException {
  super(popConfig, context, true);
  this.incoming = incoming;
  DrillConfig config = context.getConfig();
  Configuration conf = new Configuration();
  conf.set("fs.default.name", config.getString(ExecConstants.EXTERNAL_SORT_SPILL_FILESYSTEM));
  try {
    this.fs = FileSystem.get(conf);
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
  SPILL_BATCH_GROUP_SIZE = config.getInt(ExecConstants.EXTERNAL_SORT_SPILL_GROUP_SIZE);
  SPILL_THRESHOLD = config.getInt(ExecConstants.EXTERNAL_SORT_SPILL_THRESHOLD);
  dirs = Iterators.cycle(config.getStringList(ExecConstants.EXTERNAL_SORT_SPILL_DIRS));
  copierAllocator = oContext.getAllocator().getChildAllocator(
      context, PriorityQueueCopier.INITIAL_ALLOCATION, PriorityQueueCopier.MAX_ALLOCATION, true);
  FragmentHandle handle = context.getHandle();
  fileName = String.format("%s/major_fragment_%s/minor_fragment_%s/operator_%s", QueryIdHelper.getQueryId(handle.getQueryId()),
      handle.getMajorFragmentId(), handle.getMinorFragmentId(), popConfig.getOperatorId());
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:21,代码来源:ExternalSortBatch.java

示例4: getFileProperties

import com.google.common.collect.Iterators; //导入依赖的package包/类
@Override
public SortedSet<TaskOutputFilePropertySpec> getFileProperties() {
    if (fileProperties == null) {
        TaskPropertyUtils.ensurePropertiesHaveNames(filePropertiesInternal);
        Iterator<TaskOutputFilePropertySpec> flattenedProperties = Iterators.concat(Iterables.transform(filePropertiesInternal, new Function<TaskPropertySpec, Iterator<? extends TaskOutputFilePropertySpec>>() {
            @Override
            public Iterator<? extends TaskOutputFilePropertySpec> apply(TaskPropertySpec propertySpec) {
                if (propertySpec instanceof CompositeTaskOutputPropertySpec) {
                    return ((CompositeTaskOutputPropertySpec) propertySpec).resolveToOutputProperties();
                } else {
                    return Iterators.singletonIterator((TaskOutputFilePropertySpec) propertySpec);
                }
            }
        }).iterator());
        fileProperties = TaskPropertyUtils.collectFileProperties("output", flattenedProperties);
    }
    return fileProperties;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:19,代码来源:DefaultTaskOutputs.java

示例5: hash

import com.google.common.collect.Iterators; //导入依赖的package包/类
private void hash(com.google.common.hash.Hasher combinedHash, List<String> visitedFilePaths, Set<File> visitedDirs, Iterator<File> toHash) {
    while (toHash.hasNext()) {
        File file = FileUtils.canonicalize(toHash.next());
        if (file.isDirectory()) {
            if (visitedDirs.add(file)) {
                //in theory, awkward symbolic links can lead to recursion problems.
                //TODO - figure out a way to test it. I only tested it 'manually' and the feature is needed.
                File[] sortedFiles = file.listFiles();
                Arrays.sort(sortedFiles);
                hash(combinedHash, visitedFilePaths, visitedDirs, Iterators.forArray(sortedFiles));
            }
        } else if (file.isFile()) {
            visitedFilePaths.add(file.getAbsolutePath());
            combinedHash.putBytes(hasher.hash(file).asBytes());
        }
        //else an empty folder - a legit situation
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:19,代码来源:HashClassPathSnapshotter.java

示例6: getScriptErrors

import com.google.common.collect.Iterators; //导入依赖的package包/类
@Override
protected List<Diagnostic> getScriptErrors(Script script) {
	EcoreUtil.resolveAll(script.eResource());
	List<Diagnostic> diagnostics = super.getScriptErrors(script);
	Iterator<Expression> expressions = Iterators.filter(EcoreUtil2.eAll(script), Expression.class);
	List<Diagnostic> result = Lists.<Diagnostic> newArrayList(Iterables.filter(diagnostics,
			ExceptionDiagnostic.class));
	while (expressions.hasNext()) {
		Expression expression = expressions.next();
		RuleEnvironment ruleEnvironment = RuleEnvironmentExtensions.newRuleEnvironment(expression);
		Result<TypeRef> type = typeSystem.type(ruleEnvironment, expression);
		if (type.getRuleFailedException() != null) {
			Throwable cause = Throwables.getRootCause(type.getRuleFailedException());
			if (!(cause instanceof RuleFailedException)) {
				if (cause instanceof Exception) {
					result.add(new ExceptionDiagnostic((Exception) cause));
				} else {
					throw new RuntimeException(cause);
				}
			}
		}
	}
	validator.validate(script.eResource(), CheckMode.ALL, CancelIndicator.NullImpl);
	return result;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:26,代码来源:ExceptionAnalyser.java

示例7: getEntriesWithLimit

import com.google.common.collect.Iterators; //导入依赖的package包/类
private List<PlayerProfileCache.ProfileEntry> getEntriesWithLimit(int limitSize)
{
    ArrayList<PlayerProfileCache.ProfileEntry> arraylist = Lists.<PlayerProfileCache.ProfileEntry>newArrayList();

    for (GameProfile gameprofile : Lists.newArrayList(Iterators.limit(this.gameProfiles.iterator(), limitSize)))
    {
        PlayerProfileCache.ProfileEntry playerprofilecache$profileentry = this.getByUUID(gameprofile.getId());

        if (playerprofilecache$profileentry != null)
        {
            arraylist.add(playerprofilecache$profileentry);
        }
    }

    return arraylist;
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:17,代码来源:PlayerProfileCache.java

示例8: getSkinUrl

import com.google.common.collect.Iterators; //导入依赖的package包/类
public String getSkinUrl(GameProfile prof) throws ParseException {
    Collection<Property> ps = prof.getProperties().get("textures");

    if (ps == null || ps.isEmpty()) {
        return null;
    } else {
        Property p = Iterators.getLast(ps.iterator());

        JSONObject obj = (JSONObject) new JSONParser().parse(
                new String(Base64.getDecoder().decode(p.getValue())));

        obj = ((JSONObject) obj.get("textures"));
        obj = ((JSONObject) obj.get("SKIN"));
        return (String) obj.get("url");
    }
}
 
开发者ID:devcexx,项目名称:libtrails,代码行数:17,代码来源:SkinDownloader.java

示例9: getSubscribers

import com.google.common.collect.Iterators; //导入依赖的package包/类
/**
 * Gets an iterator representing an immutable snapshot of all subscribers to the given event at
 * the time this method is called.
 */
Iterator<Subscriber> getSubscribers(Object event) {
  ImmutableSet<Class<?>> eventTypes = flattenHierarchy(event.getClass());

  List<Iterator<Subscriber>> subscriberIterators =
      Lists.newArrayListWithCapacity(eventTypes.size());

  for (Class<?> eventType : eventTypes) {
    CopyOnWriteArraySet<Subscriber> eventSubscribers = subscribers.get(eventType);
    if (eventSubscribers != null) {
      // eager no-copy snapshot
      subscriberIterators.add(eventSubscribers.iterator());
    }
  }

  return Iterators.concat(subscriberIterators.iterator());
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:21,代码来源:SubscriberRegistry.java

示例10: iterator

import com.google.common.collect.Iterators; //导入依赖的package包/类
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public Iterator<Binding<?>> iterator() {
  return Iterators.transform(lookups.entrySet().iterator(), new Function<Entry<Class<?>, Resolver>, Binding<?>>(){
    @Override
    public Binding apply(Entry<Class<?>, Resolver> input) {
      switch(input.getValue().getType()){
      case INSTANCE:
        return new InstanceBinding(input.getKey(), ((InjectableReference)input.getValue()).clazz);
      case SINGLETON:
        return new SingletonBinding(input.getKey(), input.getValue().get(null));
      default:
        throw new IllegalStateException();
      }

    }});
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:18,代码来源:BinderImpl.java

示例11: testGetSubscribers

import com.google.common.collect.Iterators; //导入依赖的package包/类
public void testGetSubscribers() {
  assertEquals(0, Iterators.size(registry.getSubscribers("")));

  registry.register(new StringSubscriber());
  assertEquals(1, Iterators.size(registry.getSubscribers("")));

  registry.register(new StringSubscriber());
  assertEquals(2, Iterators.size(registry.getSubscribers("")));

  registry.register(new ObjectSubscriber());
  assertEquals(3, Iterators.size(registry.getSubscribers("")));
  assertEquals(1, Iterators.size(registry.getSubscribers(new Object())));
  assertEquals(1, Iterators.size(registry.getSubscribers(1)));

  registry.register(new IntegerSubscriber());
  assertEquals(3, Iterators.size(registry.getSubscribers("")));
  assertEquals(1, Iterators.size(registry.getSubscribers(new Object())));
  assertEquals(2, Iterators.size(registry.getSubscribers(1)));
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:20,代码来源:SubscriberRegistryTest.java

示例12: lookupNames

import com.google.common.collect.Iterators; //导入依赖的package包/类
private static void lookupNames(MinecraftServer server, Collection<String> names, ProfileLookupCallback callback)
{
    String[] astring = (String[])Iterators.toArray(Iterators.filter(names.iterator(), new Predicate<String>()
    {
        public boolean apply(@Nullable String p_apply_1_)
        {
            return !StringUtils.isNullOrEmpty(p_apply_1_);
        }
    }), String.class);

    if (server.isServerInOnlineMode())
    {
        server.getGameProfileRepository().findProfilesByNames(astring, Agent.MINECRAFT, callback);
    }
    else
    {
        for (String s : astring)
        {
            UUID uuid = EntityPlayer.getUUID(new GameProfile((UUID)null, s));
            GameProfile gameprofile = new GameProfile(uuid, s);
            callback.onProfileLookupSucceeded(gameprofile);
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:25,代码来源:PreYggdrasilConverter.java

示例13: OptionIterator

import com.google.common.collect.Iterators; //导入依赖的package包/类
public OptionIterator(FragmentContext context, Mode mode){
  final DrillConfigIterator configOptions = new DrillConfigIterator(context.getConfig());
  fragmentOptions = context.getOptions();
  final Iterator<OptionValue> optionList;
  switch(mode){
  case BOOT:
    optionList = configOptions.iterator();
    break;
  case SYS_SESS:
    optionList = fragmentOptions.iterator();
    break;
  default:
    optionList = Iterators.concat(configOptions.iterator(), fragmentOptions.iterator());
  }

  List<OptionValue> values = Lists.newArrayList(optionList);
  Collections.sort(values);
  mergedOptions = values.iterator();

}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:21,代码来源:OptionIterator.java

示例14: transform

import com.google.common.collect.Iterators; //导入依赖的package包/类
@Override
public void transform(ClassNode clazz, MethodNode method, InsnMatcher matcher) {
	AbstractInsnNode[] match = Iterators.getOnlyElement(matcher.match("BIPUSH ISTORE", m -> {
		IntInsnNode push = (IntInsnNode) m[0];
		if (push.operand != 50) {
			return false;
		}

		VarInsnNode store = (VarInsnNode) m[1];
		LocalVariableNode node = AsmUtils.getLocalVariable(method, store.var, store);
		return node != null && node.name.equals("resource") && node.desc.equals("I");
	}));

	method.instructions.remove(match[0]);
	method.instructions.remove(match[1]);
}
 
开发者ID:jonathanedgecombe,项目名称:anvil,代码行数:17,代码来源:VeinCapTransformer.java

示例15: next

import com.google.common.collect.Iterators; //导入依赖的package包/类
@Override
public Directory next() throws NoSuchElementException {
  Iterator<Digest> iter = pointers.peek();
  if (!iter.hasNext()) {
    throw new NoSuchElementException();
  }
  /* we can have null directories in our list
   * if members of the tree have been removed from
   * the cas.  we return this to retain the information
   * (and simplify the interface) that they have been
   * removed. */
  Digest digest = iter.next();
  Directory directory = expectDirectory(instance.getBlob(digest));
  if (directory != null) {
    /* the path to a new iter set is the path to its parent */
    parentPath.addLast(digest);
    path = parentPath.clone();
    pointers.push(Iterators.transform(
        directory.getDirectoriesList().iterator(),
        directoryNode -> directoryNode.getDigest()));
  }
  advanceIterator();
  return directory;
}
 
开发者ID:bazelbuild,项目名称:bazel-buildfarm,代码行数:25,代码来源:TreeIterator.java


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