Lecture overview -- Keyboard shortcut: 'u'  Previous page: Specialization of Collections - a realistic example -- Keyboard shortcut: 'p'  Next page: Sample use of class <b><kbd>List<T></kbd></b> -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home  Page 12 : 36
Object-oriented Programming in C#
Collection Classes
Overview of the class List<T>

The class List<T> offers a comprehensive repertoire of list operations

 

  • Members of the class List<T>

    • Constructors

      • List(),   List(IEnumerable<T>),   List(int)

      • Via a collection initializer: new List<T> {t1, t2, ..., tn}

    • Element access

      • this[int],   GetRange(int, int)

    • Measurement

      • Count,   Capacity

    • Element addition

      • Add(T),   AddRange(IEnumerable<T>),   Insert(int, T),
        InsertRange(int, IEnumerable<T>)

    • Element removal

      • Remove(T),   RemoveAll(Predicate<T>),   RemoveAt(int),   RemoveRange(int, int),   Clear()

    • Reorganization

      • Reverse(),   Reverse(int, int),
        Sort(),   Sort(Comparison<T>),
        Sort(IComparer<T>),   Sort(int, int, IComparer<T>)

    • Searching

      • BinarySearch(T),   BinarySearch(int, int, T, IComparer<T>),   BinarySearch(T, IComparer<T>)

      • Find(Predicate<T>),   FindAll(Predicate<T>),   FindIndex(Predicate<T>),
        FindLast(Predicate<T>),   FindLastIndex(Predicate<T>),   IndexOf(T),   LastIndexOf(T)

    • Boolean queries

      • Contains(T),   Exists(Predicate<T>),   TrueForAll(Predicate<T>)

    • Conversions

      • ConvertAll<TOutput>(Converter<T,TOutput>),   CopyTo(T[]),