ResizeableArrays and ListSlices

Resizable Arrays and List Slice are custom types for holdings set of data. If used carefully they can improve performance and productivity. There are advantages and disadvantages using these types compared to regular Lists or Arrays.

Resizable Array

A Resizable Array is a class which contains a single array. As it name suggests it allows you to resize that array. Internally the array length is only increased when necessary. If the size is reduced then the internal element count value is reduced. The Resizable Array should only be used when the size does not frequently. A List should be used if you’re unsure which object type should be used.

List Slice

A List Slice is a slice of a list. The List Slice denotes a start and end index and allows you to iterate through the elements within that start and end index. A List Slice is a struct which makes it light weight. Any object that implements the IReadOnlyList<T> interface can be converted to a List Slice. This includes Arrays, Lists and Resiazable Arrays. It is important to remember that a List Slice is not a copy of the original IReadOnlyList. If the internal list changes then the List Slice will change as well.