Constructors with capacity; foreach with index