![]() |
#17 |
Участник
|
Цитата:
Сообщение от Gustav
![]() The only situation in which you cannot avoid using the iterator is when you must remove elements from a List collection. The following code shows how this is accomplished.
X++: List list = new List(Types::Integer); ListIterator iterator; ; list.addEnd(100); list.addEnd(200); list.addEnd(300); iterator = new ListIterator(list); while (iterator.more()) { if (iterator.value() == 200) iterator.delete(); iterator.next(); } print list.toString(); //{100, 300} pause; |
|
|
За это сообщение автора поблагодарили: Gustav (2). |