Returns the index of a string. If not found, inserts the string and return the inserted index.
| 77 | // Returns the index of a string. If not found, inserts the string and |
| 78 | // return the inserted index. |
| 79 | uint64 GetIndex(const string& str) { |
| 80 | auto idx = string_id_.find(str); |
| 81 | if (idx != string_id_.end()) { |
| 82 | return idx->second; |
| 83 | } |
| 84 | all_strings_.push_back(str); |
| 85 | return string_id_.insert(std::pair<string, int64>(str, string_id_.size())) |
| 86 | .first->second; |
| 87 | } |
| 88 | |
| 89 | const std::vector<string>& strings() const { return all_strings_; } |
| 90 |