| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| IListIterator |
|
| 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 | 0 | package org.as3collections |
| 31 | { | |
| 32 | import org.as3collections.IIterator; | |
| 33 | ||
| 34 | /** | |
| 35 | * An iterator for lists that allows the programmer to traverse the list in either direction, modify the list during iteration, and obtain the iterator's current position in the list. | |
| 36 | * <p>Note that the <code>remove</code> and <code>set</code> methods are defined to operate on the last element returned by a call to <code>next</code> or <code>previous</code>.</p> | |
| 37 | * | |
| 38 | * @author Flávio Silva | |
| 39 | */ | |
| 40 | public interface IListIterator extends IIterator | |
| 41 | { | |
| 42 | /** | |
| 43 | * Inserts the specified element into the list (optional operation). The element is inserted immediately before the next element that would be returned by <code>next</code>, if any, and after the next element that would be returned by <code>previous</code>, if any. (If the list contains no elements, the new element becomes the sole element on the list.) The new element is inserted before the implicit cursor: a subsequent call to <code>next</code> would be unaffected, and a subsequent call to <code>previous</code> would return the new element. (This call increases by one the value that would be returned by a call to <code>nextIndex</code> or <code>previousIndex</code>.) | |
| 44 | * | |
| 45 | * @param element the element to add. | |
| 46 | * @throws org.as3collections.errors.ConcurrentModificationError if the list was changed directly (without using the iterator) during iteration. | |
| 47 | * @return <code>true</code> if the list has changed as a result of the call. Returns <code>false</code> if the list does not permit duplicates and already contains the specified element. | |
| 48 | */ | |
| 49 | function add(element:*): Boolean; | |
| 50 | ||
| 51 | /** | |
| 52 | * Returns <code>true</code> if the iteration has more elements when traversing the list in the reverse direction. | |
| 53 | * | |
| 54 | * @return <code>true</code> if the iteration has more elements when traversing the list in the reverse direction. | |
| 55 | */ | |
| 56 | function hasPrevious(): Boolean; | |
| 57 | ||
| 58 | /** | |
| 59 | * Returns the index of the element that would be returned by a subsequent call to <code>next</code>. (Returns list size if the list iterator is at the end of the list.) | |
| 60 | * | |
| 61 | * @return the index of the element that would be returned by a subsequent call to <code>next</code>, or list size if list iterator is at end of list. | |
| 62 | */ | |
| 63 | function nextIndex(): int; | |
| 64 | ||
| 65 | /** | |
| 66 | * Returns the previous element in the iteration. | |
| 67 | * | |
| 68 | * @throws org.as3collections.errors.NoSuchElementError if the iteration has no previous elements. | |
| 69 | * @throws org.as3collections.errors.ConcurrentModificationError if the list was changed directly (without using the iterator) during iteration. | |
| 70 | * @return the previous element in the iteration. | |
| 71 | */ | |
| 72 | function previous(): *; | |
| 73 | ||
| 74 | /** | |
| 75 | * Returns the index of the element that would be returned by a subsequent call to <code>previous</code>. (Returns -1 if the list iterator is at the beginning of the list.) | |
| 76 | * | |
| 77 | * @return the index of the element that would be returned by a subsequent call to <code>previous</code>, or -1 if list iterator is at beginning of list. | |
| 78 | */ | |
| 79 | function previousIndex(): int; | |
| 80 | ||
| 81 | /** | |
| 82 | * Replaces the last element returned by <code>next</code> or <code>previous</code> with the specified element (optional operation). This call can be made only if neither <code>IListIterator.remove</code> nor <code>IListIterator.add</code> have been called after the last call to <code>next</code> or <code>previous</code>. | |
| 83 | * | |
| 84 | * @param element the element with which to replace the last element returned by <code>next</code> or <code>previous</code>. | |
| 85 | * @throws org.as3coreaddendum.errors.UnsupportedOperationError if the <code>set</code> operation is not supported by this iterator. | |
| 86 | * @throws org.as3coreaddendum.errors.ClassCastError if the class of the specified element prevents it from being added to this list. | |
| 87 | * @throws org.as3coreaddendum.errors.IllegalStateError if neither <code>next</code> or <code>previous</code> have been called, or <code>remove</code> or <code>add</code> have been called after the last call to <code>next</code> or <code>previous</code>. | |
| 88 | */ | |
| 89 | function set(element:*): void; | |
| 90 | } | |
| 91 | ||
| 92 | } |