Search in sources :

Example 1 with BaseIterable

use of ceylon.language.impl.BaseIterable in project ceylon by eclipse.

the class Array method locations.

@Override
@TypeInfo("{ceylon.language::Entry<ceylon.language::Integer,Element>*}")
public Iterable<? extends Entry<? extends Integer, ? extends Element>, ? extends java.lang.Object> locations(@Name("selecting") @FunctionalParameter("(element)") @TypeInfo("ceylon.language::Boolean(Element&ceylon.language::Object)") final Callable<? extends Boolean> selecting) {
    final TypeDescriptor klass = TypeDescriptor.klass(Entry.class, Integer.$TypeDescriptor$, $reifiedElement);
    return new BaseIterable<Entry<? extends Integer, ? extends Element>, java.lang.Object>(klass, Null.$TypeDescriptor$) {

        @Override
        public Iterator<? extends Entry<? extends Integer, ? extends Element>> iterator() {
            return new BaseIterator<Entry<? extends Integer, ? extends Element>>(klass) {

                int index = 0;

                @Override
                public java.lang.Object next() {
                    while (index < size) {
                        Element element = unsafeItem(index);
                        if (selecting.$call$(element).booleanValue()) {
                            return new Entry(Integer.$TypeDescriptor$, $reifiedElement, Integer.instance(index++), element);
                        }
                        index++;
                    }
                    return finished_.get_();
                }
            };
        }
    };
}
Also used : TypeDescriptor(org.eclipse.ceylon.compiler.java.runtime.model.TypeDescriptor) BaseIterator(ceylon.language.impl.BaseIterator) BaseIterable(ceylon.language.impl.BaseIterable) TypeInfo(org.eclipse.ceylon.compiler.java.metadata.TypeInfo)

Aggregations

BaseIterable (ceylon.language.impl.BaseIterable)1 BaseIterator (ceylon.language.impl.BaseIterator)1 TypeInfo (org.eclipse.ceylon.compiler.java.metadata.TypeInfo)1 TypeDescriptor (org.eclipse.ceylon.compiler.java.runtime.model.TypeDescriptor)1