BiOrderedIterator
This is an ordered iterator that allows you to add items ordered by an index. The items are ordered based on the index and finding and removing an item based on its index is done in constant time. Inserting an item is in worst case O(n) (where n is the number of items in the iterator).
This class extends BiObject and therefore all methods and fields available for BiObject are also available for BiOrderedIterator .
Constructor
new BiOrderedIterator ( )
Parameters
No parameters.
Properties
Methods
| Name | Description |
add | Adds an value with an index. Adding an item using an index that already exists in the iterator overwrites the old item. |
containsIndex | Whether the iterator contains an item with the given index |
first | Resets the iterator to the first item |
getValueAt | Returns the value at the given index |
next | Advances the iterator to the next item |
remove | Removes the item at the given index and returns it. |
Events
None.
Static Methods
None.
Static Fields
None.
Remarks
None.
Method Details
add
Adds an value with an index. Adding an item using an index that already exists in the iterator overwrites the old item.
Syntax
object.add ( nIndex,val ) Parameters
| Name | Type | Optional | Default | Descripton |
nIndex | Number | The index to order the value by. | ||
val | Object | The value to add at the given index |
Return Type
void
containsIndex
Whether the iterator contains an item with the given index
Syntax
object.containsIndex ( nIndex ) Parameters
| Name | Type | Optional | Default | Descripton |
nIndex | Number | The index to check for |
Return Type
Boolean
first
Resets the iterator to the first item
Syntax
object.first ( ) Parameters
No arguments.
Return Type
void
getValueAt
Returns the value at the given index
Syntax
object.getValueAt ( nIndex ) Parameters
| Name | Type | Optional | Default | Descripton |
nIndex | Number | The index to get the value for |
Return Type
Object
next
Advances the iterator to the next item
Syntax
object.next ( ) Parameters
No arguments.
Return Type
void
remove
Removes the item at the given index and returns it.
Syntax
object.remove ( nIndex ) Parameters
| Name | Type | Optional | Default | Descripton |
nIndex | Number | The index of the value to remove |
Return Type
Object
