KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > bak > pcj > list > LongList


1 /*
2  * Primitive Collections for Java.
3  * Copyright (C) 2002 Søren Bak
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

19 package bak.pcj.list;
20
21 import bak.pcj.LongIterator;
22 import bak.pcj.LongCollection;
23
24 /**
25  * This interface represents lists of long values.
26  *
27  * @see java.util.List
28  *
29  * @author Søren Bak
30  * @version 1.2 24-08-2003 20:34
31  * @since 1.0
32  */

33 public interface LongList extends LongCollection {
34
35     /**
36      * Adds an element to this list at a specified index. All
37      * elements from the specified index and forward are pushed
38      * to their successor's indices.
39      *
40      * @param index
41      * the index at which to add the element. If
42      * <tt>index == size()</tt> the element is appended
43      * to this list.
44      *
45      * @param v
46      * the long value to add to this list.
47      *
48      * @throws UnsupportedOperationException
49      * if the operation is not supported by this
50      * list.
51      *
52      * @throws IndexOutOfBoundsException
53      * if <tt>index</tt> does not denote a valid insertion
54      * position (valid: <tt>0 - size()</tt>).
55      *
56      * @see #add(long)
57      * @see #addAll(LongCollection)
58      * @see #addAll(int,LongCollection)
59      */

60     void add(int index, long v);
61
62     /**
63      * Adds all the elements of a specified collection to
64      * this list starting at a specified index. The elements are
65      * inserted in the specified collection's iteration order.
66      * All elements from the specified index and forward are pushed
67      * to their successors' indices (<tt>c.size()</tt> indices).
68      *
69      * @param index
70      * the index at which to insert the elements of
71      * the specified collection. If
72      * <tt>index == size()</tt> the elements are appended
73      * to this list.
74      *
75      * @param c
76      * the collection whose elements to add to this
77      * list.
78      *
79      * @return <tt>true</tt> if this list was modified
80      * as a result of adding the elements of <tt>c</tt>;
81      * returns <tt>false</tt> otherwise.
82      *
83      * @throws UnsupportedOperationException
84      * if the operation is not supported by this
85      * list.
86      *
87      * @throws NullPointerException
88      * if <tt>c</tt> is <tt>null</tt>.
89      *
90      * @throws IndexOutOfBoundsException
91      * if <tt>index</tt> does not denote a valid insertion
92      * position (valid: <tt>0 - size()</tt>).
93      *
94      * @see #add(long)
95      * @see #add(int, long)
96      * @see #addAll(LongCollection)
97      */

98     boolean addAll(int index, LongCollection c);
99
100     /**
101      * Returns the element at a specified position in this list.
102      *
103      * @param index
104      * the position of the element to return.
105      *
106      * @return the element at the specified position.
107      *
108      * @throws IndexOutOfBoundsException
109      * if <tt>index</tt> does not denote a valid index
110      * in this list.
111      */

112     long get(int index);
113
114     /**
115      * Returns the index of the first occurance of a specified
116      * element in this list.
117      *
118      * @param c
119      * the element to find.
120      *
121      * @return the index of the first occurance of the specified
122      * element in this list; returns <tt>-1</tt>, if the
123      * element is not contained in this list.
124      */

125     int indexOf(long c);
126
127     /**
128      * Returns the index of the first occurance of a specified
129      * element in this list after or at a specified index.
130      *
131      * @param c
132      * the element to find.
133      *
134      * @param index
135      * the index at which to start the search.
136      *
137      * @return the index of the first occurance of the specified
138      * element in this list; returns <tt>-1</tt>, if the
139      * element is not contained in this list.
140      *
141      * @throws IndexOutOfBoundsException
142      * if <tt>index</tt> does not denote a valid
143      * iteration position (valid: <tt>0 - size()</tt>).
144      *
145      * @since 1.2
146      */

147     int indexOf(int index, long c);
148
149     /**
150      * Returns the index of the last occurance of a specified
151      * element in this list.
152      *
153      * @param c
154      * the element to find.
155      *
156      * @return the index of the last occurance of the specified
157      * element in this list; returns <tt>-1</tt>, if the
158      * element is not contained in this list.
159      */

160     int lastIndexOf(long c);
161
162     /**
163      * Returns the index of the last occurance of a specified
164      * element in this list before a specified index.
165      *
166      * @param c
167      * the element to find.
168      *
169      * @param index
170      * the index at which to start the search. Note that
171      * the element at <code>index</code> is not included
172      * in the search.
173      *
174      * @return the index of the last occurance of the specified
175      * element in this list; returns <tt>-1</tt>, if the
176      * element is not contained in this list.
177      *
178      * @throws IndexOutOfBoundsException
179      * if <tt>index</tt> does not denote a valid
180      * iteration position (valid: <tt>0 - size()</tt>).
181      *
182      * @since 1.2
183      */

184     int lastIndexOf(int index, long c);
185
186     /**
187      * Returns a list iterator over this list.
188      *
189      * @return a list iterator over this list.
190      */

191     LongListIterator listIterator();
192
193     /**
194      * Returns a list iterator over this list, starting from a
195      * specified index.
196      *
197      * @param index
198      * the index at which to begin the iteration.
199      *
200      * @return a list iterator over this list.
201      *
202      * @throws IndexOutOfBoundsException
203      * if <tt>index</tt> does not denote a valid
204      * iteration position (valid: <tt>0 - size()</tt>).
205      */

206     LongListIterator listIterator(int index);
207
208     /**
209      * Removes the element at a specified index in this list. All
210      * elements following the removed element are pushed to their
211      * predecessor's indices.
212      *
213      * @param index
214      * the index of the element to remove.
215      *
216      * @return the value of the element removed.
217      *
218      * @throws UnsupportedOperationException
219      * if the operation is not supported by this
220      * list.
221      *
222      * @throws IndexOutOfBoundsException
223      * if <tt>index</tt> does not denote a valid
224      * element position (valid: <tt>0 - size()-1</tt>).
225      */

226     long removeElementAt(int index);
227
228     /**
229      * Sets a specified element to a new value.
230      *
231      * @param index
232      * the index of the element whose value to set.
233      *
234      * @param v
235      * the new value of the specified element.
236      *
237      * @return the previous value of the element.
238      *
239      * @throws UnsupportedOperationException
240      * if the operation is not supported by this
241      * list.
242      *
243      * @throws IndexOutOfBoundsException
244      * if <tt>index</tt> does not denote a valid
245      * element position (valid: <tt>0 - size()-1</tt>).
246      */

247     long set(int index, long v);
248
249 }
Popular Tags