Skip to content

Commit

Permalink
Move methods up to abstract class and clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
pontusmelke committed May 27, 2018
1 parent 052dfcb commit cf738ac
Show file tree
Hide file tree
Showing 3 changed files with 332 additions and 378 deletions.
Expand Up @@ -588,6 +588,37 @@ public static <T> Iterator<T> iterator( int maxItems, T ... items )
return asIterator( maxItems, items );
}

public static <T> Iterator<T> appendTo( Iterator<T> iterator, T... appended )
{
return new Iterator<T>()
{
private int index;

@Override
public boolean hasNext()
{
return iterator.hasNext() || index < appended.length;
}

@Override
public T next()
{
if ( iterator.hasNext() )
{
return iterator.next();
}
else if ( index < appended.length )
{
return appended[index++];
}
else
{
throw new NoSuchElementException();
}
}
};
}

@SuppressWarnings( "unchecked" )
public static <T> ResourceIterator<T> emptyResourceIterator()
{
Expand Down

0 comments on commit cf738ac

Please sign in to comment.