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


Java Iterator类代码示例

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


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

示例1: iterator

import java.util.Iterator; //导入依赖的package包/类
/**
 * page iterator
 *
 * @return iterator
 */
public Iterator<Page> iterator() {
    return new Iterator<Page>() {
        @Override
        public boolean hasNext() {
            return mCurrentPage < mPages;
        }

        @Override
        public Page next() {
            if (hasNext()) {
                return new Page(mCurrentPage++);
            }
            return null;
        }

        @Override
        public void remove() {
        }
    };
}
 
开发者ID:cleaninsights,项目名称:cleaninsights-android-sdk,代码行数:26,代码来源:TrackerBulkURLWrapper.java

示例2: getRealm

import java.util.Iterator; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static <T> T getRealm(Class<? extends Realm> realmType){
	RealmSecurityManager securityManager = (RealmSecurityManager) SecurityUtils.getSecurityManager();
	if(!CollectionUtils.isEmpty(securityManager.getRealms())){
		for(Iterator<Realm> it = securityManager.getRealms().iterator(); it.hasNext();){
			Realm realm = it.next();
			if(realm.getClass().equals(realmType)){
				return (T) realm;
			}
		}
	}
	return null;
}
 
开发者ID:penggle,项目名称:xproject,代码行数:14,代码来源:ShiroUtils.java

示例3: matchCredentials

import java.util.Iterator; //导入依赖的package包/类
/**
 * Find matching {@link Credentials credentials} for the given authentication scope.
 *
 * @param map the credentials hash map
 * @param token the {@link AuthScope authentication scope}
 * @return the credentials 
 * 
 */
private static Credentials matchCredentials(final HashMap map, final AuthScope authscope) {
    // see if we get a direct hit
    Credentials creds = (Credentials)map.get(authscope);
    if (creds == null) {
        // Nope.
        // Do a full scan
        int bestMatchFactor  = -1;
        AuthScope bestMatch  = null;
        Iterator items = map.keySet().iterator();
        while (items.hasNext()) {
            AuthScope current = (AuthScope)items.next();
            int factor = authscope.match(current);
            if (factor > bestMatchFactor) {
                bestMatchFactor = factor;
                bestMatch = current;
            }
        }
        if (bestMatch != null) {
            creds = (Credentials)map.get(bestMatch);
        }
    }
    return creds;
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:32,代码来源:HttpState.java

示例4: iterator

import java.util.Iterator; //导入依赖的package包/类
@Override
public Iterator<V> iterator() {
    return new MapIterator<V>() {
        @Override
        public V next() {
            if (mapEntry == null) {
                throw new NoSuchElementException();
            }
            
            V value = readValue(mapEntry.getValue());
            mapEntry = null;
            return value;
        }

        @Override
        public void remove() {
            if (mapEntry == null) {
                throw new IllegalStateException();
            }
            map.remove(mapEntry.getKey(), mapEntry.getValue());
            mapEntry = null;
        }
    };
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:25,代码来源:AbstractCacheMap.java

示例5: a

import java.util.Iterator; //导入依赖的package包/类
public synchronized void a(String[] strArr) {
    for (int size = this.j.size() - 1; size >= 0; size--) {
        for (CharSequence equals : strArr) {
            if (TextUtils.equals(((e) this.j.get(size)).a, equals)) {
                this.j.remove(size);
                break;
            }
        }
    }
    Iterator it = this.j.iterator();
    int i = 0;
    while (it.hasNext()) {
        e eVar = (e) it.next();
        i = eVar.b > i ? eVar.b : i;
    }
    for (int i2 = 0; i2 < strArr.length; i2++) {
        a(new e(strArr[i2], (strArr.length + i) - i2));
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:20,代码来源:Fallback.java

示例6: getProblem

import java.util.Iterator; //导入依赖的package包/类
/**
 * Creates a support vector problem for the LibSVM.
 * 
 * @throws UserError
 */
private svm_problem getProblem(ExampleSet exampleSet) throws UserError {
	log("Creating LibSVM problem.");
	FastExample2SparseTransform ripper = new FastExample2SparseTransform(exampleSet);
	int nodeCount = 0;
	svm_problem problem = new svm_problem();
	problem.l = exampleSet.size();
	problem.y = new double[exampleSet.size()];
	problem.x = new svm_node[exampleSet.size()][];
	Iterator<Example> i = exampleSet.iterator();
	Attribute label = exampleSet.getAttributes().getLabel();
	int j = 0;
	while (i.hasNext()) {
		Example e = i.next();
		problem.x[j] = makeNodes(e, ripper);
		problem.y[j] = e.getValue(label);
		nodeCount += problem.x[j].length;
		j++;
	}
	log("Created " + nodeCount + " nodes for " + j + " examples.");
	return problem;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:27,代码来源:LibSVMLearner.java

示例7: createBlockingResultSet

import java.util.Iterator; //导入依赖的package包/类
private ResultSet<String> createBlockingResultSet(BlockingQueue<String> queue, Supplier<Boolean> finished) {
  AtomicReference<String> ref = new AtomicReference<>();
  AtomicInteger sizeref = new AtomicInteger(0);
  Iterator<String> blockingIterator = new Iterator<String>() {
    @Override
    public boolean hasNext() {
      if (ref.get() != null) return true;
      while (!finished.get()) {
        if (ref.get() != null) return true;
        try {
          ref.set(queue.poll(1000, TimeUnit.MILLISECONDS));
        } catch (InterruptedException e) {
          throw new RuntimeException(e);
        }
      }
      return ref.get() != null;
    }

    @Override
    public String next() {
      sizeref.incrementAndGet();
      return ref.getAndSet(null);
    }
  };
  return createResultSet(blockingIterator);
}
 
开发者ID:mnemonic-no,项目名称:common-services,代码行数:27,代码来源:ServiceMessageHandlerTest.java

示例8: toString

import java.util.Iterator; //导入依赖的package包/类
@Override
public String toString(){
	StringBuilder sb = new StringBuilder();
	sb.append(this.getName());
	Iterator<String> attNames = this._attrs.keySet().iterator();
	while(attNames.hasNext()){
		String attName = attNames.next();
		ArrayList<String> attValues = this._attrs.get(attName);
		sb.append("|");
		sb.append(attName);
		for(String attValue : attValues){
			sb.append(":");
			sb.append(attValue);
		}
	}
	return sb.toString();
}
 
开发者ID:justhalf,项目名称:weak-semi-crf-naacl2016,代码行数:18,代码来源:AttributedWord.java

示例9: checkElementNumber

import java.util.Iterator; //导入依赖的package包/类
/**
 * Checks number of elements within a iterator.
 * @param it iterator to check
 * @param n number of elements found
 * @return true if n equals elements number in iterator, otherwise false.
 */
public static boolean checkElementNumber (Iterator<?> it, int n)
{
   int i = 0;      
   while (it.hasNext ())
   {
      if (it.next () == null)
      {
         return false;
      }
      i++;
   }
   return (i == n);
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:20,代码来源:CheckIterator.java

示例10: combineOrdered

import java.util.Iterator; //导入依赖的package包/类
/**
 * Returns a hash code, having the same bit length as each of the input hash codes, that combines
 * the information of these hash codes in an ordered fashion. That is, whenever two equal hash
 * codes are produced by two calls to this method, it is <i>as likely as possible</i> that each
 * was computed from the <i>same</i> input hash codes in the <i>same</i> order.
 *
 * @throws IllegalArgumentException if {@code hashCodes} is empty, or the hash codes do not all
 *     have the same bit length
 */
public static HashCode combineOrdered(Iterable<HashCode> hashCodes) {
  Iterator<HashCode> iterator = hashCodes.iterator();
  checkArgument(iterator.hasNext(), "Must be at least 1 hash code to combine.");
  int bits = iterator.next().bits();
  byte[] resultBytes = new byte[bits / 8];
  for (HashCode hashCode : hashCodes) {
    byte[] nextBytes = hashCode.asBytes();
    checkArgument(
        nextBytes.length == resultBytes.length, "All hashcodes must have the same bit length.");
    for (int i = 0; i < nextBytes.length; i++) {
      resultBytes[i] = (byte) (resultBytes[i] * 37 ^ nextBytes[i]);
    }
  }
  return HashCode.fromBytesNoCopy(resultBytes);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:25,代码来源:Hashing.java

示例11: copyProbandListEntryTagValueOutToIn

import java.util.Iterator; //导入依赖的package包/类
public static void copyProbandListEntryTagValueOutToIn(ProbandListEntryTagValueInVO in, ProbandListEntryTagValueOutVO out) {
	if (in != null && out != null) {
		ProbandListEntryOutVO listEntryVO = out.getListEntry();
		ProbandListEntryTagOutVO tagVO = out.getTag();
		Collection<InputFieldSelectionSetValueOutVO> tagValueVOs = out.getSelectionValues();
		in.setBooleanValue(out.getBooleanValue());
		in.setDateValue(out.getDateValue());
		in.setTimeValue(out.getTimeValue());
		in.setFloatValue(out.getFloatValue());
		in.setId(out.getId());
		in.setListEntryId(listEntryVO == null ? null : listEntryVO.getId());
		in.setLongValue(out.getLongValue());
		ArrayList<Long> selectionValueIds = new ArrayList<Long>(tagValueVOs.size());
		Iterator<InputFieldSelectionSetValueOutVO> tagValueVOsIt = tagValueVOs.iterator();
		while (tagValueVOsIt.hasNext()) {
			selectionValueIds.add(tagValueVOsIt.next().getId());
		}
		in.setSelectionValueIds(selectionValueIds);
		in.setTagId(tagVO == null ? null : tagVO.getId());
		in.setTextValue(out.getTextValue());
		in.setTimestampValue(out.getTimestampValue());
		in.setInkValues(out.getInkValues());
		in.setVersion(out.getVersion());
	}
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:26,代码来源:ProbandListEntryTagValueBean.java

示例12: obfuscateCriterions

import java.util.Iterator; //导入依赖的package包/类
private static CriteriaOutVO obfuscateCriterions(CriteriaOutVO criteriaVO) {
	if (criteriaVO != null) {
		CriteriaOutVO result = new CriteriaOutVO(criteriaVO);
		ArrayList<CriterionOutVO> obfuscatedCriterions = new ArrayList<CriterionOutVO>();
		Iterator<CriterionOutVO> criterionsIt = criteriaVO.getCriterions().iterator();
		while (criterionsIt.hasNext()) {
			CriterionOutVO obfuscatedCriterion = new CriterionOutVO(criterionsIt.next());
			obfuscatedCriterion.setCriteria(result);
			CriterionPropertyVO property = obfuscatedCriterion.getProperty();
			if (property != null && OmittedFields.isOmitted(property.getProperty())) {
				obfuscatedCriterion.setStringValue(OmittedFields.OBFUSCATED_STRING);
			}
			obfuscatedCriterions.add(obfuscatedCriterion);
		}
		result.setCriterions(obfuscatedCriterions);
		return result;
	}
	return null;
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:20,代码来源:SearchServiceImpl.java

示例13: listWriters

import java.util.Iterator; //导入依赖的package包/类
/**
 * List any valid writers that can be found.
 * 
 * @param loader Loader to search for classes. If <code>null</code>, the system class
 *   loader is used.
 * 
 * @return A sorted list of writer names.
 */
public static String[] listWriters(URLClassLoader loader) {
	
	// Create structures
	Set<String> urlSet = SystemUtil.findSubPackages(PACKAGE_NAME, loader.getURLs(), true);
	
	Iterator<String> setIter = urlSet.iterator();
	
	while (setIter.hasNext()) {
		String url = setIter.next();
		
		try {
			getWriterClass(url, loader);
			
		} catch (Throwable ex) {
			setIter.remove();
		}
	}
	
	// Sort and return
	String[] writers = urlSet.toArray(new String[0]);
	Arrays.sort(writers);
	
	return writers;
}
 
开发者ID:paudano,项目名称:kestrel,代码行数:33,代码来源:VariantWriter.java

示例14: parse

import java.util.Iterator; //导入依赖的package包/类
@Override
public MetadataFieldMapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
    if (parserContext.indexVersionCreated().before(Version.V_1_3_0)) {
        throw new IllegalArgumentException("type="+CONTENT_TYPE+" is not supported on indices created before version 1.3.0. Is your cluster running multiple datanode versions?");
    }
    
    Builder builder = new Builder(parserContext.mapperService().fullName(NAME));
    if (parserContext.indexVersionCreated().before(Version.V_2_0_0_beta1)) {
        parseField(builder, builder.name, node, parserContext);
    }

    for (Iterator<Map.Entry<String, Object>> iterator = node.entrySet().iterator(); iterator.hasNext();) {
        Map.Entry<String, Object> entry = iterator.next();
        String fieldName = Strings.toUnderscoreCase(entry.getKey());
        Object fieldNode = entry.getValue();
        if (fieldName.equals("enabled")) {
            builder.enabled(nodeBooleanValue(fieldNode));
            iterator.remove();
        }
    }
    return builder;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:23,代码来源:FieldNamesFieldMapper.java

示例15: forEachButLast

import java.util.Iterator; //导入依赖的package包/类
/**
 * Executes the given closure on each but the last element in the iterator.
 * <p>
 * If the input iterator is null no change is made.
 *
 * @param <E> the type of object the {@link Iterator} contains
 * @param iterator  the iterator to get the input from, may be null
 * @param closure  the closure to perform, may not be null
 * @return the last element in the iterator, or null if iterator is null or empty
 * @throws NullPointerException if closure is null
 * @since 4.1
 */
public static <E> E forEachButLast(final Iterator<E> iterator, final Closure<? super E> closure) {
    if (closure == null) {
        throw new NullPointerException("Closure must not be null.");
    }
    if (iterator != null) {
        while (iterator.hasNext()) {
            final E element = iterator.next();
            if (iterator.hasNext()) {
                closure.execute(element);
            } else {
                return element;
            }
        }
    }
    return null;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:29,代码来源:IteratorUtils.java


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