Collection Complexities

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/0ac05451-d8fa-4d0d-be49-c51b0c536b20/Untitled.png

IEnumerator<T> and IEnumerable<T>

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/ca76f803-e06c-4667-bacf-a8912674850e/Untitled

var stack = new Stack<int>();
Stack<int>.Enumerator enumerator = stack.GetEnumerator();
while (enumerator.MoveNext())
{
    int number = enumerator.Current;
    Console.WriteLine(number);
}
var numbers = Enumerable.Range(1, 10).ToList();
var repeatedValues = Enumerable.Repeat("Hello World!", 5).ToArray();

ICollection<T> and IReadOnlyCollection<T>

interface ICollection<T> : IEnumerable<T>, IEnumerable
{
	int Count { get; }
	bool IsReadOnly { get; }
	void Add(T item);
	void Clear();
	bool Contains(T item);
	void CopyTo(T[] array, int arrayIndex);
	bool Remove(T item);
}
interface IReadOnlyCollection<T> : IEnumerable<T>, IEnumerable
{
	int Count { get; }
}

Collection & Array Initializer

var sevenWorldBlunders = new List<string>()
{
	"Wealth without work",
	"Pleasure without conscience"
};

var items = new [] // new string[]
{
	"Item1",
	"Item2"
};

Array

public abstract class Array : ICloneable, System.Collections.IList, 
	System.Collections.IStructuralComparable, System.Collections.IStructuralEquatable