jaroslav@557: /* jaroslav@557: * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved. jaroslav@557: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. jaroslav@557: * jaroslav@557: * This code is free software; you can redistribute it and/or modify it jaroslav@557: * under the terms of the GNU General Public License version 2 only, as jaroslav@557: * published by the Free Software Foundation. Oracle designates this jaroslav@557: * particular file as subject to the "Classpath" exception as provided jaroslav@557: * by Oracle in the LICENSE file that accompanied this code. jaroslav@557: * jaroslav@557: * This code is distributed in the hope that it will be useful, but WITHOUT jaroslav@557: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or jaroslav@557: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License jaroslav@557: * version 2 for more details (a copy is included in the LICENSE file that jaroslav@557: * accompanied this code). jaroslav@557: * jaroslav@557: * You should have received a copy of the GNU General Public License version jaroslav@557: * 2 along with this work; if not, write to the Free Software Foundation, jaroslav@557: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. jaroslav@557: * jaroslav@557: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA jaroslav@557: * or visit www.oracle.com if you need additional information or have any jaroslav@557: * questions. jaroslav@557: */ jaroslav@557: jaroslav@557: package java.util; jaroslav@557: jaroslav@557: /** jaroslav@557: * Marker interface used by List implementations to indicate that jaroslav@557: * they support fast (generally constant time) random access. The primary jaroslav@557: * purpose of this interface is to allow generic algorithms to alter their jaroslav@557: * behavior to provide good performance when applied to either random or jaroslav@557: * sequential access lists. jaroslav@557: * jaroslav@557: *

The best algorithms for manipulating random access lists (such as jaroslav@557: * ArrayList) can produce quadratic behavior when applied to jaroslav@557: * sequential access lists (such as LinkedList). Generic list jaroslav@557: * algorithms are encouraged to check whether the given list is an jaroslav@557: * instanceof this interface before applying an algorithm that would jaroslav@557: * provide poor performance if it were applied to a sequential access list, jaroslav@557: * and to alter their behavior if necessary to guarantee acceptable jaroslav@557: * performance. jaroslav@557: * jaroslav@557: *

It is recognized that the distinction between random and sequential jaroslav@557: * access is often fuzzy. For example, some List implementations jaroslav@557: * provide asymptotically linear access times if they get huge, but constant jaroslav@557: * access times in practice. Such a List implementation jaroslav@557: * should generally implement this interface. As a rule of thumb, a jaroslav@557: * List implementation should implement this interface if, jaroslav@557: * for typical instances of the class, this loop: jaroslav@557: *

jaroslav@557:  *     for (int i=0, n=list.size(); i < n; i++)
jaroslav@557:  *         list.get(i);
jaroslav@557:  * 
jaroslav@557: * runs faster than this loop: jaroslav@557: *
jaroslav@557:  *     for (Iterator i=list.iterator(); i.hasNext(); )
jaroslav@557:  *         i.next();
jaroslav@557:  * 
jaroslav@557: * jaroslav@557: *

This interface is a member of the jaroslav@557: * jaroslav@557: * Java Collections Framework. jaroslav@557: * jaroslav@557: * @since 1.4 jaroslav@557: */ jaroslav@557: public interface RandomAccess { jaroslav@557: }