source: branches/libc-0.6/src/gcc/libjava/java/util/List.java

Last change on this file was 1392, checked in by bird, 22 years ago

This commit was generated by cvs2svn to compensate for changes in r1391,
which included commits to RCS files with non-trunk default branches.

  • Property cvs2svn:cvs-rev set to 1.1.1.2
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 15.8 KB
Line 
1/* List.java -- An ordered collection which allows indexed access
2 Copyright (C) 1998, 2001 Free Software Foundation, Inc.
3
4This file is part of GNU Classpath.
5
6GNU Classpath is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11GNU Classpath is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Classpath; see the file COPYING. If not, write to the
18Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
1902111-1307 USA.
20
21Linking this library statically or dynamically with other modules is
22making a combined work based on this library. Thus, the terms and
23conditions of the GNU General Public License cover the whole
24combination.
25
26As a special exception, the copyright holders of this library give you
27permission to link this library with independent modules to produce an
28executable, regardless of the license terms of these independent
29modules, and to copy and distribute the resulting executable under
30terms of your choice, provided that you also meet, for each linked
31independent module, the terms and conditions of the license of that
32module. An independent module is a module which is not derived from
33or based on this library. If you modify this library, you may extend
34this exception to your version of the library, but you are not
35obligated to do so. If you do not wish to do so, delete this
36exception statement from your version. */
37
38
39package java.util;
40
41/**
42 * An ordered collection (also known as a list). This collection allows
43 * access to elements by position, as well as control on where elements
44 * are inserted. Unlike sets, duplicate elements are permitted by this
45 * general contract (if a subclass forbids duplicates, this should be
46 * documented).
47 * <p>
48 *
49 * List places additional requirements on <code>iterator</code>,
50 * <code>add</code>, <code>remove</code>, <code>equals</code>, and
51 * <code>hashCode</code>, in addition to requiring more methods. List
52 * indexing is 0-based (like arrays), although some implementations may
53 * require time proportional to the index to obtain an arbitrary element.
54 * The List interface is incompatible with Set; you cannot implement both
55 * simultaneously.
56 * <p>
57 *
58 * Lists also provide a <code>ListIterator</code> which allows bidirectional
59 * traversal and other features atop regular iterators. Lists can be
60 * searched for arbitrary elements, and allow easy insertion and removal
61 * of multiple elements in one method call.
62 * <p>
63 *
64 * Note: While lists may contain themselves as elements, this leads to
65 * undefined (usually infinite recursive) behavior for some methods like
66 * hashCode or equals.
67 *
68 * @author Original author unknown
69 * @author Eric Blake <[email protected]>
70 * @see Collection
71 * @see Set
72 * @see ArrayList
73 * @see LinkedList
74 * @see Vector
75 * @see Arrays#asList(Object[])
76 * @see Collections#nCopies(int, Object)
77 * @see Collections#EMPTY_LIST
78 * @see AbstractList
79 * @see AbstractSequentialList
80 * @since 1.2
81 * @status updated to 1.4
82 */
83public interface List extends Collection
84{
85 /**
86 * Insert an element into the list at a given position (optional operation).
87 * This shifts all existing elements from that position to the end one
88 * index to the right. This version of add has no return, since it is
89 * assumed to always succeed if there is no exception.
90 *
91 * @param index the location to insert the item
92 * @param o the object to insert
93 * @throws UnsupportedOperationException if this list does not support the
94 * add operation
95 * @throws IndexOutOfBoundsException if index &lt; 0 || index &gt; size()
96 * @throws ClassCastException if o cannot be added to this list due to its
97 * type
98 * @throws IllegalArgumentException if o cannot be added to this list for
99 * some other reason
100 */
101 void add(int index, Object o);
102
103 /**
104 * Add an element to the end of the list (optional operation). If the list
105 * imposes restraints on what can be inserted, such as no null elements,
106 * this should be documented.
107 *
108 * @param o the object to add
109 * @return true, as defined by Collection for a modified list
110 * @throws UnsupportedOperationException if this list does not support the
111 * add operation
112 * @throws ClassCastException if o cannot be added to this list due to its
113 * type
114 * @throws IllegalArgumentException if o cannot be added to this list for
115 * some other reason
116 */
117 boolean add(Object o);
118
119 /**
120 * Insert the contents of a collection into the list at a given position