Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  *  Copyright 2009-2014 Pavel Ponec
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
  *  You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package org.ujorm.core;
Ujo iterator have got some extended functions:
  • iterator can provide optionally a count of items by a count() method
  • iterator can be used in generic loop syntax for( : )
  • iterator can create a List object

Author(s):
Pavel Ponec
class UjoIteratorImpl<T> extends UjoIterator<T> {
    final private Iterator<T> e;
    final private long count;
    public UjoIteratorImpl(final Iterator<T> iteratorlong count) {
        this. = iterator;
        this. = count;
    }
    public UjoIteratorImpl(final Iterator<T> iterator) {
        this(iterator, -1);
    }

    
Tests if this enumeration contains more elements.
    public boolean hasNext() {
        return .hasNext();
    }

    
Returns the next element if exists.

Returns:
the next element
Throws:
java.util.NoSuchElementException no more elements exist.
    public T next() throws NoSuchElementException {
        return .next();
    }

    
Returns a count of items or value -1 if the count is not defined.
    @Override
    public long count() {
        return ;
    }
New to GrepCode? Check out our FAQ X