IMMUTABLE_TREE_R0: ImmList.java

File ImmList.java, 2.4 KB (added by stefan, 16 years ago)
Line 
1package org.sophie2.base.commons.util;
2
3import org.sophie2.core.prolib.annot.Immutable;
4
5/**
6 * Interface for an immutable list.
7 *
8 * TODO : Moved to the core library when R4 refactoring is in process.
9 * TODO : Test implementations!!!
10 * TODO : The list using black-red tree should implement it.
11 *
12 * @author meddle, mira
13 *
14 * @param <E>
15 *                      The type of the elements in the {@link ImmList}.
16 */
17@Immutable(kind = "list")
18public interface ImmList<E> extends ImmCollection<E> {
19       
20        /**
21         * Adds a value to the list.
22         *
23         * @param value
24         *                      Value.
25         * @return
26         *                      An {@link ImmList} containing the new value.
27         */     
28        ImmList<E> add(E value);
29
30        /**
31         * Adds a value to the list at the specified index.
32         *
33         * @param index
34         *                      Index.
35         * @param value
36         *                      Value.
37         * @return
38         *                      an {@link ImmList} containing the new value.
39         */
40        ImmList<E> add(int index, E value);
41       
42        /**
43         * Removes a value from the list.
44         *
45         * @param index
46         *                      Index.
47         * @return
48         *                      An {@link ImmList} without the value.
49         */     
50        ImmList<E> remove(int index);
51       
52        /**
53         * Removes a value from the list.
54         *
55         * @param value
56         *                      Value to remove.
57         * @return
58         *                      An {@link ImmList} without the value.
59         */     
60        ImmList<E> remove(E value);
61       
62        /**
63         * Sets a value at the specified index.
64         *
65         * @param index
66         *                      Index.
67         * @param value
68         *                      Value.
69         * @return
70         *                      An {@link ImmList} containing the new value.
71         */
72        ImmList<E> set(int index, E value);
73       
74        /**
75         * Gets the value at the specified index.
76         *
77         * @param index
78         *                      Index.
79         * @return
80         *                      The value at the specified index.
81         */     
82        E get(int index);
83       
84        /**
85         * Concatenates the passed <code>ImmList</code> to this.
86         *
87         * @param immList
88         *                      The <code>ImmList</code> to concatenate to this.
89         * @return
90         *                      A new <code>ImmList</code> constructed concatenating
91         *                      <var>immList</var> to this.
92         */
93        ImmList<E> concat(ImmList<E> immList);
94       
95        /**
96         * Checks if this <code>ImmList</code> contains the passed
97         * <var>element</var>.
98         *
99         * @param element
100         *                      The element to check.
101         * @return
102         *                      True if this <code>ImmList</code> contains the element
103         *                      false otherwise.
104         */
105        boolean contains(E element);
106       
107        /**
108         * Returns new {@link ImmList} limited to the specific range
109         * @param from
110         * @param to
111         * @return <code>ImmList</code>.
112         */
113        ImmList<E> subList(int from, int to);
114}