05.03.2007, 17:40 | #1 |
Участник
|
Объект List
Скажите пожалуйста, как добавлять элементы в объект list и что делают методы AddStart и AddEnd?
P.S. нужно сохранить наименование чтобы их потом просматривать, для этого и был выбран данный объект. |
|
05.03.2007, 17:48 | #2 |
Участник
|
Вот из Foundation Classes for DAX 2.5
Цитата:
Lists are structures that may contain any number of elements that are accessed sequentially. Lists may contain values of any X++ type. All the values in the list must be of the same type, given in the creation of the list. The implementation of lists is such that traversal of the list elements is very fast.
Lists may be traversed using the listIterator class, q.v. Example { // Create a list of integers list il = new list(types::integer); // Add some elements to the list il.addEnd(1); il.addEnd(2); il.addStart(3); // Print the list print il.toString(); print il.definitionString(); pause; } The following methods are available on list objects: public new (types type) Creates a list containing elements of the given type. public boolean empty() Returns TRUE if the list is empty i.e. if it does not contain any elements, and FALSE otherwise. This is equivalent to (elements() == 0) public int elements() Returns the number of elements in the list. public any addStart(any value) Add the given value to the start of the list. The element becomes the first element in the list. The value inserted is returned. public any addEnd(any value) Add the given value to the end of the list. The element becomes the last element in the list. The value inserted is returned. public boolean equalTo (list l) Returns TRUE if the given list is identical to the list on which the method is called and FALSE otherwise. Two lists are equal to another list if the two lists contain the same number of elements and the elements occur in the same order. This is a shorthand for using the static equal method: equal(this, l). public int typeId() Returns the type of the values in the list. container pack() Packs the list into a container, suitable for saving in a database etc. If the elements are objects, the pack method is called on each object to yield a (sub) container. public str toString() Returns a human readable form of the list, e.g <”Peter”, “Paul”, “Mary”> public str definitionString() Returns a string containing the definition of the list, e.g. “list of int”. public static list merge (list l1, list l2) Returns a list formed by appending the list l2 onto the list l1. The types of the lists must be the same. public static boolean equal(list l1, list l2) Returns TRUE if the two given lists are identical. Two lists are equal to another list if the two lists contain the same number of elements and the elements occur in the same order. public static list create(container c) Create the list from the container obtained from a prior call to pack, q.v. 2.2 ListIterators List iterators are used to iterate over the elements in a list. They may be viewed as simply pointers into the lists over which they iterate. Functionality is available to start the iteratation, to determine whether or not more elements are available and to fetch the element pointed to by the iterator. The order in which the elements occur during iteration is defined by the sequence in which the elements are inserted using the addStart and addEnd methods. ListIterators and the lists over which they iterate must be on the same Client/Server side. Example { list il = new list(types::integer); listIterator it; // Add some elements into the list... il.addStart(1); il.addStart(2); il.addStart(4); // Create a list iterator it = new listIterator (il); print it.definitionString(); // prints “int list iterator” print it.toString(); // prints “(begin)[4]” // Go on for as long as elements are found in the list... while (it.more()) { // fetch the next element print it.value(); // prints 4 2 1 it.next(); } print it.toString(); // prints (end) pause; } The following methods are available on list iterator objects public new (set s) Create a new iterator for the given list. The iterator is positioned at the first value in the list, if the list is nonempty. public any value() Returns the value denoted by the iterator. It is an error to attempt to retrieve the value of an iterator that does not point to anything (i.e where more() returns FALSE). public boolean more() Returns TRUE if more elements are available in the list and FALSE otherwise. It is an error to access the elements pointed to by an iterator when this function returns FALSE. public void next() Moves the iterator to the next element. public void begin() Moves the iterator to the start of the list. public void end() Moves the iterator past the last element in the list. After executing this function more() will return FALSE. public void delete() Removes the element pointed to by the iterator from the list. The iterator will point to the next element. public str toString() Returns a textual representation of the iterator. If the iterator points to the first element in the set, the string will contain an indication of this, in the form: “(begin)[value]” If the iterator does not point to an element (i.e more() returns FALSE), the string returned is: “(end)” If the iterator points to a value the string is: “[value]” where value is a string representation of the element value. public str definitionString() Returns a textual representation of the type of the iterator, e.g. “int list iterator” |
|
Теги |
ax2.5 |
|
Опции темы | Поиск в этой теме |
Опции просмотра | |
|