.. default-domain:: chpl .. module:: List :synopsis: This module contains the implementation of Chapel's standard 'list' type. List ==== **Usage** .. code-block:: chapel use List; or .. code-block:: chapel import List; This module contains the implementation of Chapel's standard 'list' type. A list is a lightweight container similar to an array that is suitable for building up and iterating over a collection of elements in a structured manner. The highly parallel nature of Chapel means that great care should be taken when performing operations that may invalidate references to list elements. Inserts and removals into the middle of a list are example operations that may invalidate references. Appending an element to the end of a list will never invalidate references to elements contained in the list. The following operations may invalidate references to elements contained in a list: - insert - remove - pop - clear - sort Additionally, all references to list elements are invalidated when the list is deinitialized. Lists are not parallel safe by default, but can be made parallel safe by setting the param formal `parSafe` to true in any list constructor. When constructed from another list, the new list will inherit the parallel safety mode of its originating list. Note that the ``parSafe`` mode is currently unstable and will eventually be replaced by a standalone parallel-safe list type. Inserts and removals into a list are O(n) worst case and should be performed with care. Appends into a list have an amortized speed of O(1). Indexing into a list is O(1). .. record:: list : serializable A list is a lightweight container suitable for building up and iterating over a collection of elements in a structured manner. Unlike a stack, the list type also supports inserts or removals into the middle of the list. The list type is close in spirit to its Python counterpart, with fast O(1) random access and append operations. The list type is not parallel safe by default. For situations in which such protections are desirable, parallel safety can be enabled by setting `parSafe = true` in any list constructor. Unlike an array, the set of indices of a list is always `0..