Skip to main content
This is lesson 8 of 14 in this module Course 38% complete

Pre-sizing Lists

Premium Content

Sign in with your account or sign up to access this lesson.

The lesson explains the internal doubling-expansion algorithm that generic List uses when capacity is exhausted, and how pre-allocating capacity with the constructor's int parameter eliminates those copy operations. We discuss when pre-sizing is worth the effort and introduce arrays as the fastest alternative when the element count is known in advance.