@Override protected void closeIterator() { if ( graphIter != null ) NiceIterator.close(graphIter) ; graphIter = null ; }
@SuppressWarnings("unchecked") @Override public <X extends T> ExtendedIterator<T> andThen( Iterator<X> it ) { return it instanceof ExtendedIterator ? (ExtendedIterator<T>) it : super.andThen( it ) ; } }
/** Answer a list of the elements in order, consuming this iterator. */ @Override public List<T> toList() { return asList( this ); }
/** Answer a list of the elements in order, consuming this iterator. */ @Override public Set<T> toSet() { return asSet( this ); }
protected void ensureHasNext() { if (hasNext() == false) throw new NoSuchElementException(); }
@Override public Set<Triple> toSet() { return NiceIterator.asSet(this); } }
@Override protected void closeIterator() { if ( iterator != null ) { NiceIterator.close(iterator) ; iterator = null ; } }
/** make a new iterator, which is us then the other chap. */ @Override public <X extends T> ExtendedIterator<T> andThen( Iterator<X> other ) { return andThen( this, other ); }
@Override public List<Triple> toList() { return NiceIterator.asList(this); }
/** if <code>it</code> is a Closableiterator, close it. Abstracts away from tests [that were] scattered through the code. */ public static void close( Iterator<?> it ) { NiceIterator.close( it ); } }
@Override public <X extends Triple> ExtendedIterator<Triple> andThen(Iterator<X> other) { return NiceIterator.<Triple>andThen(this, other); }
@Override protected void closeIterator() { if ( graphIter != null ) NiceIterator.close(graphIter) ; graphIter = null ; }
@Override protected void closeIterator() { if ( iterator != null ) { NiceIterator.close(iterator) ; iterator = null ; } }
@Override public void close() { NiceIterator.close( base ); } }
public void close() { if ( iter != null ) NiceIterator.close(iter) ; }
public void close() { if ( iter != null ) NiceIterator.close(iter) ; }
/** Answer the elements of the given iterator as a list, in the order that they arrived from the iterator. The iterator is consumed by this operation: even if an exception is thrown, the iterator will be closed. @param it the iterator to convert @return a list of the elements of <code>it</code>, in order */ public static <T> List<T> iteratorToList( Iterator<? extends T> it ) { List<T> result = new ArrayList<T>(); try { while (it.hasNext()) result.add( it.next() ); } finally { NiceIterator.close( it ); } return result; }
@Override protected void closeIterator() { if ( iterator != null ) { NiceIterator.close(iterator) ; // In case we wrapped, for example, another QueryIterator. Iter.close(iterator) ; iterator = null ; } }
/** Answer the elements of the given iterator as a set. The iterator is consumed by the operation. Even if an exception is thrown, the iterator will be closed. @param i the iterator to convert @return A set of the members of i */ public static <T> Set<T> iteratorToSet( Iterator<? extends T> i ) { Set<T> result = CollectionFactory.createHashedSet(); try { while (i.hasNext()) result.add( i.next() ); } finally { NiceIterator.close( i ); } return result; }