Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
IListMap |
|
| 0.0;0 |
1 | /* | |
2 | * Licensed under the MIT License | |
3 | * | |
4 | * Copyright 2010 (c) Flávio Silva, http://flsilva.com | |
5 | * | |
6 | * Permission is hereby granted, free of charge, to any person | |
7 | * obtaining a copy of this software and associated documentation | |
8 | * files (the "Software"), to deal in the Software without | |
9 | * restriction, including without limitation the rights to use, | |
10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell | |
11 | * copies of the Software, and to permit persons to whom the | |
12 | * Software is furnished to do so, subject to the following | |
13 | * conditions: | |
14 | * | |
15 | * The above copyright notice and this permission notice shall be | |
16 | * included in all copies or substantial portions of the Software. | |
17 | * | |
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | |
20 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
21 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | |
22 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | |
23 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | |
25 | * OTHER DEALINGS IN THE SOFTWARE. | |
26 | * | |
27 | * http://www.opensource.org/licenses/mit-license.php | |
28 | */ | |
29 | ||
30 | 1 | package org.as3collections |
31 | { | |
32 | /** | |
33 | * An ordered map. | |
34 | * The user of this interface has precise control over where in the map each mapping is inserted. | |
35 | * The user can access mappings by their integer index (position in the map), and search for mappings in the map. | |
36 | * <p>The <code>IListMap</code> interface provides the special <code>IListMapIterator</code> iterator, that allows mapping insertion and replacement, and bidirectional access in addition to the normal operations that the <code>IIterator</code> interface provides. | |
37 | * The <code>listMapIterator()</code> method is provided to obtain a <code>IListMapIterator</code> implementation that may start at a specified position in the map.</p> | |
38 | * <p>This interface has the purpose to, in certain degree, unify <code>IList</code> and <code>IMap</code> interfaces.</p> | |
39 | * <p>The methods that modify the map are specified to throw <code>org.as3coreaddendum.errors.UnsupportedOperationError</code> if the map does not support the operation. | |
40 | * These methods are documented as "optional operation".</p> | |
41 | * | |
42 | * @see org.as3collections.AbstractListMap AbstractListMap | |
43 | * @see org.as3collections.IMap IMap | |
44 | * @see org.as3collections.ISortedMap ISortedMap | |
45 | * @see org.as3collections.IListMapIterator IListMapIterator | |
46 | * @author Flávio Silva | |
47 | */ | |
48 | public interface IListMap extends IMap | |
49 | { | |
50 | /** | |
51 | * The number of times this map has been <em>structurally modified</em>. | |
52 | * Structural modifications are those that change the size of the map. | |
53 | * <p>This field is used by the <code>IListMapIterator</code> implementation returned by the <code>listMapIterator</code> method. | |
54 | * If the value of this field changes unexpectedly, the <code>IListMapIterator</code> object will throw a <code>org.as3collections.errors.ConcurrentModificationError</code> in response to the <code>next</code>, <code>remove</code>, <code>previous</code> or <code>put</code> operations.</p> | |
55 | * <p>Implementations merely has to increment this field in its <code>put</code>, <code>remove</code> and any other methods that result in structural modifications to the map. | |
56 | * A single call to <code>put</code> or <code>remove</code> must add no more than one to this field.</p> | |
57 | * | |
58 | */ | |
59 | function get modCount(): int; | |
60 | ||
61 | /** | |
62 | * Returns the key at the specified position in this map. | |
63 | * | |
64 | * @param index index of the key to return. | |
65 | * @throws org.as3collections.errors.IndexOutOfBoundsError if the index is out of range <code>(index < 0 || index >= size())</code>. | |
66 | * @return the key at the specified position in this map. | |
67 | */ | |
68 | function getKeyAt(index:int): *; | |
69 | ||
70 | /** | |
71 | * Returns the value at the specified position in this map. | |
72 | * | |
73 | * @param index index of the value to return. | |
74 | * @throws org.as3collections.errors.IndexOutOfBoundsError if the index is out of range <code>(index < 0 || index >= size())</code>. | |
75 | * @return the value at the specified position in this map. | |
76 | */ | |
77 | function getValueAt(index:int): *; | |
78 | ||
79 | /** | |
80 | * Returns a new <code>IListMap</code> object that is a view of the portion of this map whose keys are strictly less than <code>toKey</code>. | |
81 | * The returned map supports all optional map operations that this map supports. | |
82 | * | |
83 | * @param toKey high endpoint (exclusive) of the keys in the returned map. | |
84 | * @throws ArgumentError if <code>toKey</code> is <code>null</code> and this map does not permit <code>null</code> keys. | |
85 | * @throws ArgumentError if <code>containsKey(toKey)</code> returns <code>false</code>. | |
86 | * @return a new <code>IListMap</code> that is a view of the portion of this map whose keys are strictly less than <code>toKey</code>. | |
87 | */ | |
88 | function headMap(toKey:*): IListMap; | |
89 | ||
90 | /** | |
91 | * Returns the index of the <em>first occurrence</em> of the specified key in this map, or -1 if this map does not contain the key. | |
92 | * | |
93 | * @param key the key to search for. | |
94 | * @throws org.as3coreaddendum.errors.ClassCastError if the class of the specified key is incompatible with this map (optional). | |
95 | * @throws ArgumentError if the specified key is <code>null</code> and this map does not permit <code>null</code> keys (optional). | |
96 | * @return the index of the first occurrence of the specified key in this map, or -1 if this map does not contain the key. | |
97 | */ | |
98 | function indexOfKey(key:*): int; | |
99 | ||
100 | /** | |
101 | * Returns the index of the <em>first occurrence</em> of the specified value in this map, or -1 if this map does not contain the value. | |
102 | * | |
103 | * @param value the value to search for. | |
104 | * @throws org.as3coreaddendum.errors.ClassCastError if the class of the specified value is incompatible with this map (optional). | |
105 | * @throws ArgumentError if the specified value is <code>null</code> and this map does not permit <code>null</code> values (optional). | |
106 | * @return the index of the first occurrence of the specified value in this map, or -1 if this map does not contain the value. | |
107 | */ | |
108 | function indexOfValue(value:*): int; | |
109 | ||
110 | /** | |
111 | * Returns a <code>IListMapIterator</code> object to iterate over the mappings in this map (in proper sequence), starting at the specified position in this map. | |
112 | * The specified index indicates the first value that would be returned by an initial call to <code>next</code>. | |
113 | * An initial call to <code>previous</code> would return the value with the specified index minus one. | |
114 | * | |
115 | * @param index index of first value to be returned from the iterator (by a call to the <code>next</code> method) | |
116 | * @return a <code>IListMapIterator</code> object to iterate over the mappings in this map (in proper sequence), starting at the specified position in this map. | |
117 | */ | |
118 | function listMapIterator(index:int = 0): IListMapIterator; | |
119 | ||
120 | /** | |
121 | * Copies all of the mappings from the specified map to this map (optional operation). | |
122 | * Shifts the entry currently at that position (if any) and any subsequent entries to the right (increases their indices). | |
123 | * The new entries will appear in this map in the order that they are returned by the specified map's iterator. | |
124 | * | |
125 | * @param index index at which to insert the first entry from the specified map. | |
126 | * @param map mappings to be stored in this map. | |
127 | * @throws org.as3coreaddendum.errors.UnsupportedOperationError if the <code>putAllAt</code> operation is not supported by this map. | |
128 | * @throws org.as3coreaddendum.errors.ClassCastError if the type of a key or value in the specified map is incompatible with this map. | |
129 | * @throws ArgumentError if the specified map is <code>null</code>, or if this map does not permit <code>null</code> keys or values, and the specified map contains <code>null</code> keys or values. | |
130 | * @throws ArgumentError if the specified map contains one or more keys already added in this map. | |
131 | */ | |
132 | function putAllAt(index:int, map:IMap): void; | |
133 | ||
134 | /** | |
135 | * Associates the specified value with the specified key at the specified position in this map (optional operation). | |
136 | * Shifts the entry currently at that position (if any) and any subsequent entries to the right (adds one to their indices). | |
137 | * | |
138 | * @param index index at which the specified entry is to be inserted. | |
139 | * @param key key with which the specified value is to be associated. | |
140 | * @param value value to be associated with the specified key. | |
141 | * @throws org.as3coreaddendum.errors.UnsupportedOperationError if the <code>putAt</code> operation is not supported by this map. | |
142 | * @throws org.as3coreaddendum.errors.ClassCastError if the type of the specified key or value is incompatible with this map. | |
143 | * @throws ArgumentError if the specified key or value is <code>null</code> and this map does not permit <code>null</code> keys or values. | |
144 | * @throws ArgumentError if this map already contains the specified key. | |
145 | * @throws org.as3collections.errors.IndexOutOfBoundsError if the index is out of range <code>(index < 0 || index > size())</code>. | |
146 | */ | |
147 | function putAt(index:int, key:*, value:*): void; | |
148 | ||
149 | /** | |
150 | * Removes the mapping at the specified position in this map (optional operation). | |
151 | * Shifts any subsequent mappings to the left (subtracts one from their indices). | |
152 | * Returns an <code>IMapEntry</code> object containing the mapping (key/value) that was removed from the map. | |
153 | * | |
154 | * @param index the index of the mapping to be removed. | |
155 | * @throws org.as3coreaddendum.errors.UnsupportedOperationError if the <code>removeAt</code> operation is not supported by this map. | |
156 | * @throws org.as3collections.errors.IndexOutOfBoundsError if the index is out of range <code>(index < 0 || index >= size())</code>. | |
157 | * @return an <code>IMapEntry</code> object containing the mapping (key/value) that was removed from the map. | |
158 | */ | |
159 | function removeAt(index:int): IMapEntry; | |
160 | ||
161 | /** | |
162 | * Removes all of the mappings whose index is between <code>fromIndex</code>, inclusive, and <code>toIndex</code>, exclusive (optional operation). | |
163 | * Shifts any subsequent mappings to the left (subtracts their indices). | |
164 | * <p>If <code>toIndex == fromIndex</code>, this operation has no effect.</p> | |
165 | * | |
166 | * @param fromIndex the index to start removing mappings (inclusive). | |
167 | * @param toIndex the index to stop removing mappings (exclusive). | |
168 | * @throws org.as3coreaddendum.errors.UnsupportedOperationError if the <code>removeRange</code> operation is not supported by this map. | |
169 | * @throws org.as3collections.errors.IndexOutOfBoundsError if <code>fromIndex</code> or <code>toIndex</code> is out of range <code>(index < 0 || index > size())</code>. | |
170 | * @return a new map containing all the removed mappings. | |
171 | */ | |
172 | function removeRange(fromIndex:int, toIndex:int): IListMap; | |
173 | ||
174 | /** | |
175 | * Reverses the order of the mappings in this map. | |
176 | */ | |
177 | function reverse(): void; | |
178 | ||
179 | /** | |
180 | * Replaces the key at the specified position in this map with the specified key (optional operation). | |
181 | * | |
182 | * @param index index of the key to replace. | |
183 | * @param key key to be stored at the specified position. | |
184 | * @throws org.as3coreaddendum.errors.UnsupportedOperationError if the <code>setKeyAt</code> operation is not supported by this map. | |
185 | * @throws org.as3coreaddendum.errors.ClassCastError if the class of the specified key prevents it from being added to this map. | |
186 | * @throws ArgumentError if the specified key is <code>null</code> and this map does not permit <code>null</code> keys. | |
187 | * @throws ArgumentError if this map already contains the specified key. | |
188 | * @throws org.as3collections.errors.IndexOutOfBoundsError if the index is out of range <code>(index < 0 || index >= size())</code>. | |
189 | * @return the key previously at the specified position. | |
190 | */ | |
191 | function setKeyAt(index:int, key:*): *; | |
192 | ||
193 | /** | |
194 | * Replaces the value at the specified position in this map with the specified value (optional operation). | |
195 | * | |
196 | * @param index index of the value to replace. | |
197 | * @param value value to be stored at the specified position. | |
198 | * @throws org.as3coreaddendum.errors.UnsupportedOperationError if the <code>setValueAt</code> operation is not supported by this map. | |
199 | * @throws org.as3coreaddendum.errors.ClassCastError if the class of the specified value prevents it from being added to this map. | |
200 | * @throws ArgumentError if the specified value is <code>null</code> and this map does not permit <code>null</code> values. | |
201 | * @throws org.as3collections.errors.IndexOutOfBoundsError if the index is out of range <code>(index < 0 || index >= size())</code>. | |
202 | * @return the value previously at the specified position. | |
203 | */ | |
204 | function setValueAt(index:int, value:*): *; | |
205 | ||
206 | /** | |
207 | * Returns a new <code>IListMap</code> object that is a view of the portion of this map between the specified <code>fromIndex</code>, inclusive, and <code>toIndex</code>, exclusive. | |
208 | * <p>The returned map supports all of the optional map operations supported by this map.</p> | |
209 | * | |
210 | * @param fromIndex the index to start retrieving mappings (inclusive). | |
211 | * @param toIndex the index to stop retrieving mappings (exclusive). | |
212 | * @throws org.as3coreaddendum.errors.UnsupportedOperationError if the <code>subMap</code> operation is not supported by this map. | |
213 | * @throws org.as3collections.errors.IndexOutOfBoundsError if <code>fromIndex</code> or <code>toIndex</code> is out of range <code>(index < 0 || index > size())</code>. | |
214 | * @return a new map that is a view of the specified range within this map. | |
215 | */ | |
216 | function subMap(fromIndex:int, toIndex:int): IListMap; | |
217 | ||
218 | /** | |
219 | * Returns a new <code>IListMap</code> object that is a view of the portion of this map whose keys are greater than or equal to <code>fromKey</code>. | |
220 | * The returned map supports all optional map operations that this map supports. | |
221 | * | |
222 | * @param fromKey low endpoint (inclusive) of the keys in the returned map. | |
223 | * @throws ArgumentError if <code>fromKey</code> is <code>null</code> and this map does not permit <code>null</code> keys. | |
224 | * @throws ArgumentError if <code>containsKey(fromKey)</code> returns <code>false</code>. | |
225 | * @return a new map that is a view of the portion of this map whose keys are greater than or equal to <code>fromKey</code>. | |
226 | */ | |
227 | function tailMap(fromKey:*): IListMap; | |
228 | } | |
229 | ||
230 | } |