public synchronized void appendBuffer(long initialTimestamp, MemoryBuffer buffer) throws TException, IOException { // filter out empty records but add a warning to the alert log Predicate<LogRecord> isNonEmpty = new Predicate<LogRecord>() { public boolean apply(LogRecord r) { if (!isValidRecord(r)) { throw new RuntimeException( String.format( "At least one of the records was missing a docid: code=%s | fields: %s | vars: %s | categories: %s", r.get_index_code(), r.get_fields(), r.get_variables(), r.get_categories())); } if (!r.is_set_docid()) { alertLogger.warn("Tried to append an empty record for index %s", r.get_index_code()); return false; } return true; } }; // write the actual segment Segment.createUnsortedSegment( root, getSegmentsPath(), initialTimestamp, Iterators.filter( new RecordIterator( null, buffer.protocol, "Buffer for " + this.code + " at " + initialTimestamp), isNonEmpty)); sort(false); }
@Override public FollowElement createFollowElement(AbstractElement current, int lookAhead) { if (logger.isDebugEnabled()) logger.debug("Creating FollowElement for: " + current); FollowElement result = new FollowElement(); result.setLookAhead(lookAhead); if (lookAhead != 1) { int from = input.index(); int to = input.size(); if (marked > 0) { from = firstMarker; } List<LookAheadTerminal> lookAheadTerminals = Lists.newArrayListWithExpectedSize(to - from); for (int tokenIndex = from; tokenIndex < to; tokenIndex++) { Token token = input.get(tokenIndex); if (token != null) { LookAheadTerminal lookAheadTerminal = createLookAheadTerminal(token); lookAheadTerminals.add(lookAheadTerminal); } } result.setLookAheadTerminals(lookAheadTerminals); result.setLookAhead(lookAheadTerminals.size() + 1); } result.setGrammarElement(current); result.setTrace( Lists.newArrayList(Iterators.filter(grammarElements.iterator(), AbstractElement.class))); result.setLocalTrace( Lists.newArrayList(Iterators.filter(localTrace.iterator(), AbstractElement.class))); result.setParamStack(Lists.newArrayList(paramStack)); if (current instanceof UnorderedGroup) { if (indexToHandledElements != null) { int index = grammarElements.lastIndexOf(current); List<AbstractElement> alreadyHandled = Lists.newArrayList( Iterators.filter( indexToHandledElements.get(index).iterator(), AbstractElement.class)); result.setHandledUnorderedGroupElements(alreadyHandled); } else { result.setHandledUnorderedGroupElements(Collections.<AbstractElement>emptyList()); } } if (logger.isDebugEnabled()) { logger.debug("FollowElement is: " + current); logger.debug("=================================="); } return result; }
/** * TODO - make Generator aware of Iterator. * * @param context * @param component * @return */ protected Iterable<MessageForRender> getVisibleMessages( FacesContext context, UIComponent component) { String forId = getFor(component); Iterator<MessageForRender> messages = getMessages(context, forId, component); UnmodifiableIterator<MessageForRender> filteredMessages = Iterators.filter(messages, getMessagesLevelFilter(context, component)); return Lists.newArrayList(filteredMessages); }
public Iterable<Tag> in(Resource r) { Iterator<Task> tasks = Iterators.filter(r.getAllContents(), Task.class); Iterable<Tag> result = Collections.emptyList(); while (tasks.hasNext()) { result = concat(tasks.next().getTags(), result); } return result; }
@SuppressWarnings("unchecked") private Iterator<Node> getBlankNodesIterator() throws RepositoryException { final Iterator<Property> properties = resource().getNode().getProperties(); final Iterator<Property> references = Iterators.filter( properties, uncheck((final Property p) -> REFERENCE_TYPES.contains(p.getType()))::test); final Iterator<Node> nodes = Iterators.transform( new PropertyValueIterator(references), UncheckedFunction.uncheck( (final Value v) -> v.getType() == PATH ? session().getNode(v.getString()) : session().getNodeByIdentifier(v.getString())) ::apply); return Iterators.filter(nodes, isSkolemNode::test); }
/** * Do the actual work and move the original documents content to a new one. * * @return the aggregated document. */ public Document merge() { Document result = MarkupFactory.eINSTANCE.createDocument(); for (Document root : roots) { Iterator<Section> it = Iterators.filter(root.eAllContents(), Section.class); while (it.hasNext()) { Section sec = it.next(); sec.setLevel(sec.getLevel() + 1); } result.getContent().addAll(root.getContent()); } return result; }
/** * Stages the object addressed by {@code pathFilter}, or all unstaged objects if {@code pathFilter * == null} to be added, if it is/they are marked as an unstaged change. Does nothing otherwise. * * <p>To stage changes not yet staged, a diff tree walk is performed using the current staged * {@link RevTree} as the old object and the current unstaged {@link RevTree} as the new object. * Then all the differences are traversed and the staged tree is updated with the changes reported * by the diff walk (neat). * * @param progress the progress listener for this process * @param pathFilter the filter to use */ public void stage(final ProgressListener progress, final @Nullable String pathFilter) { // short cut for the case where the index is empty and we're staging all changes in the // working tree, so it's just a matter of updating the index ref to working tree RevTree id if (null == pathFilter && !index().getStaged(null).hasNext() && !updateOnly && index().countConflicted(null) == 0) { progress.started(); Optional<ObjectId> workHead = command(RevParse.class).setRefSpec(Ref.WORK_HEAD).call(); if (workHead.isPresent()) { command(UpdateRef.class).setName(Ref.STAGE_HEAD).setNewValue(workHead.get()).call(); } progress.setProgress(100f); progress.complete(); return; } final long numChanges = workingTree().countUnstaged(pathFilter).count(); Iterator<DiffEntry> unstaged = workingTree().getUnstaged(pathFilter); if (updateOnly) { unstaged = Iterators.filter( unstaged, new Predicate<DiffEntry>() { @Override public boolean apply(@Nullable DiffEntry input) { // HACK: avoid reporting changed trees if (input.isChange() && input.getOldObject().getType().equals(TYPE.TREE)) { return false; } return input.getOldObject() != null; } }); } index().stage(progress, unstaged, numChanges); List<Conflict> conflicts = index().getConflicted(pathFilter); ConflictsDatabase conflictsDatabase = conflictsDatabase(); for (Conflict conflict : conflicts) { // if we are staging unmerged files, the conflict should get solved. However, if the // working index object is the same as the staging area one (for instance, after running // checkout --ours), it will not be reported by the getUnstaged method. We solve that // here. conflictsDatabase.removeConflict(null, conflict.getPath()); } }
private void removeExpensiveXtextAnnotations(IProgressMonitor monitor) { List<Annotation> issues = Lists.newArrayList(); Iterator<XtextAnnotation> xtext = Iterators.filter(fAnnotationModel.getAnnotationIterator(), XtextAnnotation.class); while (xtext.hasNext() && !monitor.isCanceled()) { final XtextAnnotation annotation = xtext.next(); Issue issue = annotation.getIssue(); if (!annotation.isMarkedDeleted() && isRelevantAnnotationType(annotation.getType()) && issue.getType() == CheckType.EXPENSIVE) { issues.add(annotation); } } updateAnnotations(monitor, issues, Maps.<Annotation, Position>newHashMap()); }
private Iterator<SimpleFeature> filter( Iterator<SimpleFeature> plainFeatures, final ObjectId filterFeatureTypeId) { return Iterators.filter( plainFeatures, new Predicate<SimpleFeature>() { @Override public boolean apply(SimpleFeature input) { RevFeatureType type; type = (RevFeatureType) input.getUserData().get(RevFeatureType.class); ObjectId metadataId = type.getId(); boolean applies = filterFeatureTypeId.equals(metadataId); return applies; } }); }
private Iterator<SimpleFeature> force( Iterator<SimpleFeature> plainFeatures, final ObjectId forceMetadataId) { return Iterators.filter( plainFeatures, new Predicate<SimpleFeature>() { @Override public boolean apply(SimpleFeature input) { RevFeatureType type; type = (RevFeatureType) input.getUserData().get(RevFeatureType.class); ObjectId metadataId = type.getId(); if (!forceMetadataId.equals(metadataId)) { throw new GeoToolsOpException(StatusCode.MIXED_FEATURE_TYPES); } return true; } }); }
private void removeExpensiveAndFastMarkerAnnotations(IProgressMonitor monitor) { // every markerAnnotation produced by fast validation can be marked as deleted. // If its predicate still holds, the validation annotation will be covered anyway. Iterator<MarkerAnnotation> annotationIterator = Iterators.filter(fAnnotationModel.getAnnotationIterator(), MarkerAnnotation.class); while (annotationIterator.hasNext() && !monitor.isCanceled()) { final MarkerAnnotation annotation = annotationIterator.next(); if (!annotation.isMarkedDeleted()) { try { IMarker marker = annotation.getMarker(); if (isRelevantAnnotationType(annotation.getType()) && marker.isSubtypeOf(MarkerTypes.EXPENSIVE_VALIDATION)) { annotation.markDeleted(true); queueOrFireAnnotationChangedEvent(annotation); } } catch (CoreException e) { // marker type cannot be resolved - keep state of annotation } } } }
public static List<DataStoreInfo> findGeogitStores(Request request) { List<DataStoreInfo> geogitStores; Catalog catalog = getCatalog(request); org.opengis.filter.Filter filter = Predicates.equal("type", GeoGitDataStoreFactory.DISPLAY_NAME); CloseableIterator<DataStoreInfo> stores = catalog.list(DataStoreInfo.class, filter); try { Predicate<DataStoreInfo> enabled = new Predicate<DataStoreInfo>() { @Override public boolean apply(@Nullable DataStoreInfo input) { return input.isEnabled(); } }; geogitStores = ImmutableList.copyOf(Iterators.filter(stores, enabled)); } finally { stores.close(); } return geogitStores; }
private static ImageDescriptor findImageDescriptor(TreeItemCreationTool createTool) { ImageDescriptor descriptor = DTreeViewerManager.getImageRegistry() .getDescriptor(DTreeViewerManager.CREATE_TREE_ITEM_IMG); EObject created = null; Iterator<CreateInstance> createInstances = Iterators.filter(createTool.eAllContents(), CreateInstance.class); while (created == null && createInstances.hasNext()) { CreateInstance map = createInstances.next(); created = CreateToolItemAction.tryToInstanciateType(createTool, created, map.getTypeName()); } Iterator<TreeItemMapping> it = createTool.getMapping().iterator(); while (created == null && it.hasNext()) { TreeItemMapping map = it.next(); created = CreateToolItemAction.tryToInstanciateType(createTool, created, map.getDomainClass()); } if (created != null) { final IItemLabelProvider labelProvider = (IItemLabelProvider) TreeUIPlugin.getPlugin() .getItemProvidersAdapterFactory() .adapt(created, IItemLabelProvider.class); if (labelProvider != null) { ImageDescriptor semanticDescriptor = ExtendedImageRegistry.getInstance().getImageDescriptor(labelProvider.getImage(created)); if (semanticDescriptor != null) { descriptor = semanticDescriptor; } } } return descriptor; }
/** * Ensures that at most <code>n</code> are up and running. If less nodes that <code>n</code> are * running this method will not start any additional nodes. */ public synchronized void ensureAtMostNumNodes(int n) { if (nodes.size() <= n) { return; } // prevent killing the master if possible final Iterator<NodeAndClient> values = n == 0 ? nodes.values().iterator() : Iterators.filter( nodes.values().iterator(), Predicates.not(new MasterNodePredicate(getMasterName()))); final Iterator<NodeAndClient> limit = Iterators.limit(values, nodes.size() - n); logger.info("reducing cluster size from {} to {}", nodes.size() - n, n); Set<NodeAndClient> nodesToRemove = new HashSet<NodeAndClient>(); while (limit.hasNext()) { NodeAndClient next = limit.next(); nodesToRemove.add(next); next.close(); } for (NodeAndClient toRemove : nodesToRemove) { nodes.remove(toRemove.name); } }
@Override protected Iterator<Calendar> iterator() { // wrap an iterator over services Iterator<Calendar> calIt = Iterators.transform( feed.services.values().iterator(), new Function<Service, Calendar>() { @Override public Calendar apply(Service s) { return s.calendar; } }); // not every service has a calendar (e.g. TriMet has no calendars, just calendar dates). // This is legal GTFS, so skip services with no calendar return Iterators.filter( calIt, new Predicate<Calendar>() { @Override public boolean apply(Calendar c) { return c != null; } }); }
/** Wraps another iterator and throws away nulls. */ public static <T> Iterator<T> removeNull(final Iterator<T> itr) { return com.google.common.collect.Iterators.filter(itr, Predicates.notNull()); }
public Iterator<TypedVar> getDeclarativelyUnboundVarsWithoutTypes() { return Iterators.filter(getVars(), DECLARATIVELY_UNBOUND_VARS_WITHOUT_TYPES); }
private static Iterator<SimpleFeature> getFeatures( final RevTree typeTree, final ObjectDatabase database, final ObjectId defaultMetadataId, final ProgressListener progressListener) { Iterator<NodeRef> nodes = new DepthTreeIterator("", defaultMetadataId, typeTree, database, Strategy.FEATURES_ONLY); // progress reporting nodes = Iterators.transform( nodes, new Function<NodeRef, NodeRef>() { private AtomicInteger count = new AtomicInteger(); @Override public NodeRef apply(NodeRef input) { progressListener.setProgress((count.incrementAndGet() * 100.f) / typeTree.size()); return input; } }); Function<NodeRef, SimpleFeature> asFeature = new Function<NodeRef, SimpleFeature>() { private Map<ObjectId, FeatureBuilder> ftCache = Maps.newHashMap(); @Override @Nullable public SimpleFeature apply(final NodeRef input) { final ObjectId metadataId = input.getMetadataId(); final RevFeature revFeature = database.getFeature(input.getObjectId()); FeatureBuilder featureBuilder = getBuilderFor(metadataId); Feature feature = featureBuilder.build(input.name(), revFeature); feature.getUserData().put(Hints.USE_PROVIDED_FID, true); feature.getUserData().put(RevFeature.class, revFeature); feature.getUserData().put(RevFeatureType.class, featureBuilder.getType()); if (feature instanceof SimpleFeature) { return (SimpleFeature) feature; } return null; } private FeatureBuilder getBuilderFor(final ObjectId metadataId) { FeatureBuilder featureBuilder = ftCache.get(metadataId); if (featureBuilder == null) { RevFeatureType revFtype = database.getFeatureType(metadataId); featureBuilder = new FeatureBuilder(revFtype); ftCache.put(metadataId, featureBuilder); } return featureBuilder; } }; Iterator<SimpleFeature> asFeatures = Iterators.transform(nodes, asFeature); UnmodifiableIterator<SimpleFeature> filterNulls = Iterators.filter(asFeatures, Predicates.notNull()); return filterNulls; }
/** * Executes the export operation using the parameters that have been specified. * * @return a FeatureCollection with the specified features */ @Override protected SimpleFeatureStore _call() { final ObjectDatabase database = objectDatabase(); if (filterFeatureTypeId != null) { RevObject filterType = database.getIfPresent(filterFeatureTypeId); checkArgument( filterType instanceof RevFeatureType, "Provided filter feature type is does not exist"); } final SimpleFeatureStore targetStore = getTargetStore(); final String refspec = resolveRefSpec(); final String treePath = refspec.substring(refspec.indexOf(':') + 1); final RevTree rootTree = resolveRootTree(refspec); final NodeRef typeTreeRef = resolTypeTreeRef(refspec, treePath, rootTree); final ObjectId defaultMetadataId = typeTreeRef.getMetadataId(); final RevTree typeTree = database.getTree(typeTreeRef.getObjectId()); final ProgressListener progressListener = getProgressListener(); progressListener.started(); progressListener.setDescription( "Exporting from " + path + " to " + targetStore.getName().getLocalPart() + "... "); final Iterator<SimpleFeature> filtered; { final Iterator<SimpleFeature> plainFeatures = getFeatures(typeTree, database, defaultMetadataId, progressListener); Iterator<SimpleFeature> adaptedFeatures = adaptToArguments(plainFeatures, defaultMetadataId); Iterator<Optional<Feature>> transformed = Iterators.transform(adaptedFeatures, ExportOp.this.function); Iterator<SimpleFeature> result = Iterators.filter( Iterators.transform( transformed, new Function<Optional<Feature>, SimpleFeature>() { @Override public SimpleFeature apply(Optional<Feature> input) { return (SimpleFeature) input.orNull(); } }), Predicates.notNull()); // check the resulting schema has something to contribute PeekingIterator<SimpleFeature> peekingIt = Iterators.peekingIterator(result); if (peekingIt.hasNext()) { Function<AttributeDescriptor, String> toString = new Function<AttributeDescriptor, String>() { @Override public String apply(AttributeDescriptor input) { return input.getLocalName(); } }; SimpleFeature peek = peekingIt.peek(); Set<String> sourceAtts = new HashSet<String>( Lists.transform(peek.getFeatureType().getAttributeDescriptors(), toString)); Set<String> targetAtts = new HashSet<String>( Lists.transform(targetStore.getSchema().getAttributeDescriptors(), toString)); if (Sets.intersection(sourceAtts, targetAtts).isEmpty()) { throw new GeoToolsOpException( StatusCode.UNABLE_TO_ADD, "No common attributes between source and target feature types"); } } filtered = peekingIt; } FeatureCollection<SimpleFeatureType, SimpleFeature> asFeatureCollection = new BaseFeatureCollection<SimpleFeatureType, SimpleFeature>() { @Override public FeatureIterator<SimpleFeature> features() { return new DelegateFeatureIterator<SimpleFeature>(filtered); } }; // add the feature collection to the feature store final Transaction transaction; if (transactional) { transaction = new DefaultTransaction("create"); } else { transaction = Transaction.AUTO_COMMIT; } try { targetStore.setTransaction(transaction); try { targetStore.addFeatures(asFeatureCollection); transaction.commit(); } catch (final Exception e) { if (transactional) { transaction.rollback(); } Throwables.propagateIfInstanceOf(e, GeoToolsOpException.class); throw new GeoToolsOpException(e, StatusCode.UNABLE_TO_ADD); } finally { transaction.close(); } } catch (IOException e) { throw new GeoToolsOpException(e, StatusCode.UNABLE_TO_ADD); } progressListener.complete(); return targetStore; }
default Iterator<ClassFileResource> classFileFilteringIterator(Iterator<ClassFileResource> it) { return Iterators.filter( it, classFileResource -> classFileResource.getName().endsWith(".class")); }
@Override public Iterator<TitanElement> getNew(final StandardElementQuery query) { Preconditions.checkArgument( query.getType() == StandardElementQuery.Type.VERTEX || query.getType() == StandardElementQuery.Type.EDGE); if (query.getType() == StandardElementQuery.Type.VERTEX && hasModifications()) { // Collect all keys from the query - ASSUMPTION: query is an AND of KeyAtom final Set<TitanKey> keys = Sets.newHashSet(); KeyAtom<TitanKey> standardIndexKey = null; for (KeyCondition<TitanKey> cond : query.getCondition().getChildren()) { KeyAtom<TitanKey> atom = (KeyAtom<TitanKey>) cond; if (atom.getRelation() == Cmp.EQUAL && isVertexIndexProperty(atom.getKey())) standardIndexKey = atom; keys.add(atom.getKey()); } Iterator<TitanVertex> vertices; if (standardIndexKey == null) { Set<TitanVertex> vertexSet = Sets.newHashSet(); for (TitanRelation r : addedRelations.getView( new Predicate<InternalRelation>() { @Override public boolean apply(@Nullable InternalRelation relation) { return keys.contains(relation.getType()); } })) { vertexSet.add(((TitanProperty) r).getVertex()); } for (TitanRelation r : deletedRelations.values()) { if (keys.contains(r.getType())) { TitanVertex v = ((TitanProperty) r).getVertex(); if (!v.isRemoved()) vertexSet.add(v); } } vertices = vertexSet.iterator(); } else { vertices = Iterators.transform( newVertexIndexEntries .get(standardIndexKey.getCondition(), standardIndexKey.getKey()) .iterator(), new Function<TitanProperty, TitanVertex>() { @Nullable @Override public TitanVertex apply(@Nullable TitanProperty o) { return o.getVertex(); } }); } return (Iterator) Iterators.filter( vertices, new Predicate<TitanVertex>() { @Override public boolean apply(@Nullable TitanVertex vertex) { return query.matches(vertex); } }); } else if (query.getType() == StandardElementQuery.Type.EDGE && !addedRelations.isEmpty()) { return (Iterator) addedRelations .getView( new Predicate<InternalRelation>() { @Override public boolean apply(@Nullable InternalRelation relation) { return (relation instanceof TitanEdge) && !relation.isHidden() && query.matches(relation); } }) .iterator(); } else throw new IllegalArgumentException("Unexpected type: " + query.getType()); }
@Override public Iterator<TitanElement> execute(final StandardElementQuery query) { Iterator<TitanElement> iter = null; if (!query.hasIndex()) { log.warn( "Query requires iterating over all vertices [{}]. For better performance, use indexes", query.getCondition()); if (query.getType() == StandardElementQuery.Type.VERTEX) { iter = (Iterator) getVertices().iterator(); } else if (query.getType() == StandardElementQuery.Type.EDGE) { iter = (Iterator) getEdges().iterator(); } else throw new IllegalArgumentException("Unexpected type: " + query.getType()); iter = Iterators.filter( iter, new Predicate<TitanElement>() { @Override public boolean apply(@Nullable TitanElement element) { return query.matches(element); } }); } else { String index = query.getIndex(); log.debug("Answering query [{}] with index {}", query, index); // Filter out everything not covered by the index KeyCondition<TitanKey> condition = query.getCondition(); // ASSUMPTION: query is an AND of KeyAtom Preconditions.checkArgument(condition instanceof KeyAnd); Preconditions.checkArgument(condition.hasChildren()); List<KeyCondition<TitanKey>> newConds = Lists.newArrayList(); boolean needsFilter = false; for (KeyCondition<TitanKey> c : condition.getChildren()) { KeyAtom<TitanKey> atom = (KeyAtom<TitanKey>) c; if (getGraph() .getIndexInformation(index) .supports(atom.getKey().getDataType(), atom.getRelation()) && atom.getKey().hasIndex(index, query.getType().getElementType()) && atom.getCondition() != null) { newConds.add(atom); } else { log.debug( "Filtered out atom [{}] from query [{}] because it is not indexed or not covered by the index"); needsFilter = true; } } Preconditions.checkArgument( !newConds.isEmpty(), "Invalid index assignment [%s] to query [%s]", index, query); final StandardElementQuery indexQuery; if (needsFilter) { Preconditions.checkArgument( !newConds.isEmpty(), "Query has been assigned an index [%s] in error: %s", query.getIndex(), query); indexQuery = new StandardElementQuery( query.getType(), KeyAnd.of(newConds.toArray(new KeyAtom[newConds.size()])), query.getLimit(), index); } else { indexQuery = query; } try { iter = Iterators.transform( indexCache .get( indexQuery, new Callable<List<Object>>() { @Override public List<Object> call() throws Exception { return graph.elementQuery(indexQuery, txHandle); } }) .iterator(), new Function<Object, TitanElement>() { @Nullable @Override public TitanElement apply(@Nullable Object id) { Preconditions.checkNotNull(id); if (id instanceof Long) return (TitanVertex) getVertex((Long) id); else if (id instanceof RelationIdentifier) return (TitanElement) getEdge((RelationIdentifier) id); else throw new IllegalArgumentException("Unexpected id type: " + id); } }); } catch (Exception e) { throw new TitanException("Could not call index", e); } if (needsFilter) { iter = Iterators.filter( iter, new Predicate<TitanElement>() { @Override public boolean apply(@Nullable TitanElement element) { return element != null && !element.isRemoved() && !isDeleted(query, element) && query.matches(element); } }); } else { iter = Iterators.filter( iter, new Predicate<TitanElement>() { @Override public boolean apply(@Nullable TitanElement element) { return element != null && !element.isRemoved() && !isDeleted(query, element); } }); } } return iter; }
@Override public Iterator<E> iterator() { return Iterators.filter(unfiltered.iterator(), predicate); }
@Override public Iterator<E> getEdges(Predicate<? super E> filter) { return Iterators.filter(getEdges(), filter); }
@Override public Iterator<V> getVertices(Predicate<? super V> filter) { return Iterators.filter(getVertices(), filter); }
@Override public Iterator<E> getOutEdges(V vertex, Predicate<? super E> filter) { return Iterators.filter(getOutEdges(vertex), filter); }
public Iterator iterator() { return Iterators.filter(this.field_148748_b.iterator(), Predicates.notNull()); }
@Override public Maybe<JsonElement> apply(JsonElement input) { JsonArray array = input.getAsJsonArray(); Iterator<JsonElement> filtered = Iterators.filter(array.iterator(), predicate); return Maybe.next(filtered); }
@Override @Deprecated public Iterator<E> iterator() { return limit(Iterators.filter(delegate.iterator(), predicate)); }