new LinkedListIterator(startpos, list)
A Linked List Iterator used to traverse and modify elements in a Linked List,
Parameters:
Name | Type | Description |
---|---|---|
startpos |
Integer | the start position of this Iterator |
list |
js_cols.LinkedList | the list to iterate |
Methods
-
add(element)
-
Inserts a new element after the current position, and moves the Iterator forward to this new elemnt
Parameters:
Name Type Description element
* the new element to insert
-
hasNext() → {Boolean}
-
Checks if the iterator has a next element
Returns:
- Type
- Boolean
-
hasPrevious() → {Boolean}
-
Checks if the iterator has a previous element
Returns:
- Type
- Boolean
-
next() → {*}
-
Moves the Iterator 1 step forward, and returns the new element reached
Returns:
the new element reached
- Type
- *
-
previous() → {*}
-
Moves the Iterator 1 step backwards, and returns the new element reached
Returns:
the new element reached
- Type
- *
-
remove() → {*}
-
Removes the element at the current position, and moves the Iterator to the previous element
Returns:
the removed element
- Type
- *
-
set(element)
-
Replaces the element at the current position
Parameters:
Name Type Description element
* the new element to replace the current position