List
A list is an ordered collection of elements of the same data type, which can be dynamically resized.
Create an empty list and add elements to the list:
typescript
let list = new List<Number>(Number);
for(let i = 0; i<3; i++){
list.Add(i);
}成员变量
List.items : T[] |
| Returns all elements of the list. |
List.count : number |
| Returns the number of elements in the list. |
成员方法
List.get ( index : number ) : T|undefined |
| Get the value of an element based on its index (index starts from 0). |
List.IndexOf ( val : T ) : number |
| Get the index value of the specified element. |
List.Add ( item : T ) : void |
| Adds an element to the end of the list. |
List.AddRange ( objects : `T[] |
| Add a group of elements to the list. |
List.Insert ( index : number , item : T ) : void |
| Inserts an element at the specified index position in the list. |
List.InsertRange ( index : number , objects : `T[] |
| Inserts a group of elements at the specified index position in the list. |
List.RemoveAt ( index : number ) : void |
| Removes the element at the specified index from the list. |
List.Remove ( val : T ) : void |
| Removes the specified element from the list (this method only removes the first occurrence of the element). |
List.RemoveRange ( index : number , count : number ) : void |
| Removes a specified range of elements from the list. |
List.Reverse ( ) : void |
| Reverses the order of elements in a list. |
List.Sort ( sort_function : Function ) : void |
| Sorts the elements in the list. |
List.Clear ( ) : void |
| Clears all elements in the list. |
List.Swap ( rhs : List<T> ) : void |
| Swaps the elements in the current list with the elements in the specified list. |
List.toString ( ) : string |
| Returns the string representation of the current List object. |
List.forEach ( callback : Callback ) : void |
| Iterates through a list. |
