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