View Javadoc

1   /*
2    *  Copyright 2001-2010 Stephen Colebourne
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   */
16  package org.joda.primitives.list;
17  
18  import java.util.List;
19  
20  import org.joda.primitives.collection.PrimitiveCollection;
21  
22  /**
23   * Base interface for all primitive list interfaces.
24   * <p>
25   * This interface extends {@link List} allowing seamless integration with other APIs.
26   * All List methods can be used, using the primitive wrapper class.
27   * However, it will be <em>much</em> more efficient to use the direct primitive methods
28   * in the subinterface.
29   * 
30   * @author Stephen Colebourne
31   * @since 1.0
32   */
33  public interface PrimitiveList<E> extends PrimitiveCollection<E>, List<E> {
34  
35      // Mandatory operations
36      //-----------------------------------------------------------------------
37      /**
38       * Gets the first list value.
39       *
40       * @return value at index zero, or null if the size is zero
41       */
42      E first();
43  
44      /**
45       * Gets the last list value.
46       *
47       * @return value at index <code>size() - 1</code> or null if the size is zero
48       */
49      E last();
50  
51      // Optional operations
52      //-----------------------------------------------------------------------
53      /**
54       * Removes a range of values from the list (optional operation).
55       * <p>
56       * This method is optional, throwing an UnsupportedOperationException if the
57       * list cannot be modified.
58       *
59       * @param fromIndexInclusive  the start of the range to remove, inclusive
60       * @param toIndexExclusive  the end of the range to remove, exclusive
61       * @return <code>true</code> if the collection was modified
62       * @throws IndexOutOfBoundsException if the index is invalid
63       * @throws UnsupportedOperationException if remove is not supported
64       */
65      boolean removeRange(int fromIndexInclusive, int toIndexExclusive);
66  
67  }