commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Janek Bogucki <jane...@yahoo.co.uk>
Subject CollectionsUtils.slice: role of 'end'?
Date Thu, 13 Dec 2001 21:31:53 GMT
Does anyone know the intention of this method? I'm
confused about the role 'end' has. It only affects the
method logic when end == start.

Many Thanks,
Janek

org.apache.commons.util.CollectionsUtils

    static public Collection slice(Collection coll,
int start, int end) {
        if(coll == null) {
            return null;
        }
        Iterator iterator = coll.iterator();
        Collection sub =
(Collection)ClassUtils.createObject(coll.getClass());
        end -= start;
        while(iterator.hasNext()) {
            if(start == 0) {
                if(end == 0) {
                    break;
                } else {
                    sub.add(iterator.next());
                }
            } else {
                iterator.next();   // ignore
                start--;
            }
        }
        return sub;
    }


__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message