Tuesday, February 7, 2012

List in X++ / Dynamics AX

List is a type of data structure and collections, it can contain unlimited items, in x++, list can be created of several Types(specified in the Types base enum), the type must be specified on the declaration and it cannot be changed after the initialization.

There are some classes exists to enumerated and iterate the list object. ListIterator object has methods that can insert and deleted items from list,  ListEnumeration cannot modify the list content


Example:

    List           myList       = new List(Types::Integer);
    List           myListString = new List(Types::String);
    ListIterator   literator  

    // add the element at the end of the list
    myList.addEnd(2); 

    // add the element at the start of the list
    myList.addStart(3); 

    myList.addEnd(7); 

    myListString.addEnd ("Second");

    myListString.addStart ("First"); 

    // If you want to insert the data at some specific index, then you need to make use of the listIterator class 

    // Iterator performs a midpoint 

    // insert at current position.

    literator = new ListIterator(myListString);

    while (literator.more())
    {
        // can provide some condition, i.e. if check etc
        if (literator.value() == "First")
        {
            listIterator.insert ("Between first and second");
        }
    } 



21 comments:

  1. How do we compare two lists in X++?

    ReplyDelete
  2. yo need to add the iterator.next() inside the while

    ReplyDelete
  3. How if my list is class type, how do I change the value in it.

    ReplyDelete
  4. The Poker Room at Mohegan Sun: All You Need To Know
    Mohegan Sun is a 진주 출장마사지 casino 김해 출장안마 in Uncasville, Connecticut, 평택 출장안마 with a total of 4,700 rooms. There are over 1600 slot machines, 태백 출장안마 video poker 남양주 출장샵 machines, a live table

    ReplyDelete
  5. sali ch**ya community ha

    ReplyDelete