Collection Classes
- slide 9 : 36
Sample use of class
Collection<T>
Similar program for
List<T>
Basic operations on a Collection of characters.
Output of the program with basic operations on a Collection of characters.
Lessons learned:
The indexer
lst[idx] = expr
mutates an existing element in the collection
The length of the collection is unchanged
The
Insert
operation splices a new element into the collection
Push subsequent elements towards the end of the collection
Makes the collection longer
The
Remove
and
RemoveAt
operations take elements out of the collections
Pull subsequent elements towards the beginning of the collection
Makes the collection shorter