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

NameTypegetsetDescripton
countNumbercheckedThe number of items in the iterator
currentIndexNumbercheckedReturns the index of the curren item
currentValueObjectcheckedReturns the value for the current item.
doneBooleancheckedWhether the iterator is finished (has passed the end).

Methods

NameDescription
addAdds an value with an index. Adding an item using an index that already exists in the iterator overwrites the old item.
containsIndexWhether the iterator contains an item with the given index
firstResets the iterator to the first item
getValueAtReturns the value at the given index
nextAdvances the iterator to the next item
removeRemoves 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

NameTypeOptionalDefaultDescripton
nIndexNumberThe index to order the value by.
valObjectThe 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

NameTypeOptionalDefaultDescripton
nIndexNumberThe 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

NameTypeOptionalDefaultDescripton
nIndexNumberThe 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

NameTypeOptionalDefaultDescripton
nIndexNumberThe index of the value to remove

Return Type

Object