Search in sources :

Example 46 with ListIterator

use of java.util.ListIterator in project Lucee by lucee.

the class GatewayUtil method toCFML.

public static Object toCFML(List list) {
    ListIterator it = list.listIterator();
    int index;
    while (it.hasNext()) {
        index = it.nextIndex();
        list.set(index, toCFML(it.next()));
    }
    return list;
}
Also used : ListIterator(java.util.ListIterator)

Example 47 with ListIterator

use of java.util.ListIterator in project jPOS by jpos.

the class ISOMultiFieldPackager method unpack.

/**
 * @param m      - the ISOComponent to receive the value consumed from ...
 * @param b      - the byte[] holding the raw message
 * @param offset - the current position within b.
 */
public int unpack(ISOComponent m, byte[] b, int offset) throws ISOException {
    ListIterator i = possibles.listIterator();
    while (i.hasNext()) {
        try {
            current = (ISOFieldPackager) i.next();
            ISOField f = new ISOField();
            int consumed = current.unpack(f, b, offset);
            m.setValue(f.getValue());
            return consumed;
        } catch (ISOException eok) {
            current = null;
        }
    }
    throw new ISOException("unpack failed in List process!");
}
Also used : ISOField(org.jpos.iso.ISOField) ISOException(org.jpos.iso.ISOException) ListIterator(java.util.ListIterator)

Example 48 with ListIterator

use of java.util.ListIterator in project jPOS by jpos.

the class ISOMultiFieldPackager method unpack.

/**
 * Unpack the passed InputStream into an ISOComponent from our list of possibles.
 * The InputStream *must* support mark!
 */
public void unpack(ISOComponent c, InputStream in) throws IOException, ISOException {
    if (!in.markSupported()) {
        throw new ISOException("InputStream passed to ISOMultFieldPackager *must* support the mark method.");
    }
    ListIterator i = possibles.listIterator();
    // Save our position in the InputStream
    in.mark(1024);
    while (i.hasNext()) {
        in.reset();
        try {
            // One of our possibles will succeed in it's unpack from this Stream.
            current = (ISOFieldPackager) i.next();
            current.unpack(c, in);
            return;
        } catch (ISOException eok) {
            // This one failed.
            current = null;
        } catch (IOException eok) {
            // This one failed.
            current = null;
        }
    }
    throw new ISOException("unpack failed to find a match in the possible List!");
}
Also used : ISOException(org.jpos.iso.ISOException) IOException(java.io.IOException) ListIterator(java.util.ListIterator)

Example 49 with ListIterator

use of java.util.ListIterator in project vcell by virtualcell.

the class ArrayUtils method iteratorBinarySearch.

private static int iteratorBinarySearch(List list, Object key) {
    int low = 0;
    int high = list.size() - 1;
    ListIterator i = list.listIterator();
    while (low <= high) {
        int mid = (low + high) >> 1;
        Object midVal = get(i, mid);
        int cmp = ((Comparable) midVal).compareTo(key);
        if (cmp < 0)
            low = mid + 1;
        else if (cmp > 0)
            high = mid - 1;
        else
            // key found
            return mid;
    }
    // key not found
    return -(low + 1);
}
Also used : ListIterator(java.util.ListIterator)

Example 50 with ListIterator

use of java.util.ListIterator in project vcell by virtualcell.

the class ListPolynomial method subtract.

public Polynomial subtract(Polynomial polynomial) {
    if (polynomial.signum() == 0)
        return this;
    if (mutable) {
        ListPolynomial q = (ListPolynomial) polynomial;
        ListIterator it1 = content.listIterator(content.size());
        ListIterator it2 = q.content.listIterator(q.content.size());
        Term t1 = it1.hasPrevious() ? (Term) it1.previous() : null;
        Term t2 = it2.hasPrevious() ? (Term) it2.previous() : null;
        while (t2 != null) {
            int c = t1 == null ? 1 : (t2 == null ? -1 : -ordering.compare(t1.monomial(), t2.monomial()));
            if (c < 0) {
                t1 = it1.hasPrevious() ? (Term) it1.previous() : null;
            } else {
                if (c > 0) {
                    if (t1 != null)
                        it1.next();
                    it1.add(t2.negate());
                } else {
                    Term t = t1.subtract(t2);
                    if (t.signum() == 0)
                        it1.remove();
                    else
                        it1.set(t);
                }
                t1 = it1.hasPrevious() ? (Term) it1.previous() : null;
                t2 = it2.hasPrevious() ? (Term) it2.previous() : null;
            }
        }
        degree = degree(this);
        sugar = Math.max(sugar, q.sugar);
        normalized = false;
        return this;
    } else
        return copy().subtract(polynomial);
}
Also used : ListIterator(java.util.ListIterator)

Aggregations

ListIterator (java.util.ListIterator)121 ArrayList (java.util.ArrayList)42 List (java.util.List)41 LinkedList (java.util.LinkedList)26 Iterator (java.util.Iterator)21 Map (java.util.Map)12 Handler (com.sun.jsftemplating.annotation.Handler)8 AbstractList (java.util.AbstractList)7 HashMap (java.util.HashMap)7 AbstractSequentialList (java.util.AbstractSequentialList)6 IOException (java.io.IOException)5 RandomAccess (java.util.RandomAccess)5 SelectResults (org.apache.geode.cache.query.SelectResults)5 Test (org.junit.Test)5 File (java.io.File)4 HashSet (java.util.HashSet)4 NoSuchElementException (java.util.NoSuchElementException)4 SipURI (javax.sip.address.SipURI)4 ArgumentIntKey (lucee.runtime.type.scope.ArgumentIntKey)4 StructTypeImpl (org.apache.geode.cache.query.internal.types.StructTypeImpl)4