10 if (shape.size() == 0) {
14 size_t max_width = shape_[0].size();
16 for (
size_t i = 1; i < shape_.size(); i++) {
17 if (shape_[i].length() > max_width) {
18 max_width = shape_[i].length();
22 for (
size_t i = 0; i < shape_.size(); i++) {
23 if (shape_[i].length() < max_width) {
24 shape_[i] = shape_[i] + string(max_width - shape_[i].length(),
kPadChar);
35 throw std::out_of_range(
"col must be nonnegative");
38 throw std::out_of_range(
"col must be < width");
41 throw std::out_of_range(
"row must be nonnegative");
44 throw std::out_of_range(
"row must be < height");
46 return shape_[row][col];
Shape(std::vector< std::string > shape)
Take in an array of lines and right-pad the shorter ones with ' ' to the width of the longest line.
char charAt(int col, int row) const
Fetch the character at the given coordinate pair.