Показать сообщение отдельно
Старый 13.05.2008, 19:05   #1  
Blog bot is offline
Blog bot
Участник
 
25,643 / 848 (80) +++++++
Регистрация: 28.10.2006
Developer notes: Be careful whith Collections and Maps in Axapta
Источник: http://axdevnotes.blogspot.com/2008/...-and-maps.html
==============

Let`s review block of code listed below.
X++:
    List list     = new List(Types::String);
    ListIterator    iterator;
    ;
    list.addEnd("a");
    list.addEnd("b");
    list.addEnd("c");
    list.addEnd("d");   
        iterator = new ListIterator(list);    
              while (iterator.more())
    {
        if (iterator.value() == "b")
            list.addEnd("e");       
              iterator.next();
    }

        info(list.toString());
There is instance of List class retaining arbitrary string values. ListIterator class is instantiated for traversing through elements in the list. What will happen when we try to add a new element in the list inside iteration block? New element will be added to collection! In Java for iterators implemented other behavior. If an iterator is obtained, modifying the underlying collection will throw a ConcurrentModificationException. Pay attantion to this difference.


Источник: http://axdevnotes.blogspot.com/2008/...-and-maps.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.