Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Inserts a new value at the position in the list that the iterator currently points to.
Syntax
public anytype insert(anytype value)
Run On
Called
Parameters
- value
Type: anytype
The value of the item to insert into the list.
Return Value
Type: anytype
The value that was inserted into the list.
Remarks
The value parameter must be the same type as the list.
Examples
The following example creates a list that has ten items and then uses the ListIterator.insert method to insert a new value as the third item in the list.
{
List il = new List(Types::Integer);
ListIterator it;
int i;
int j = 25;
// Insert values 1 to 10 into the list
for (i = 1; i <= 10; i++)
{
il.addEnd(i);
}
// Go to the 3rd element in the list
it = new ListIterator(il);
it.begin();
it.next();
it.next();
// Insert a new value (25)
it.insert(j);
it.begin();
// Print all values in the list.
// 25 is the third value in the list
while (it.more())
{
print it.value();
it.next();
}
pause;
}