SparseToCompact takes a sparse index to an index in the compact space. Uses a binary search to find the result. For faster speed use IndexMapBiDi, but that takes more memory.
| 25 | // Uses a binary search to find the result. For faster speed use |
| 26 | // IndexMapBiDi, but that takes more memory. |
| 27 | int IndexMap::SparseToCompact(int sparse_index) const { |
| 28 | int result = compact_map_.binary_search(sparse_index); |
| 29 | return compact_map_[result] == sparse_index ? result : -1; |
| 30 | } |
| 31 | |
| 32 | // Copy from the input. |
| 33 | void IndexMap::CopyFrom(const IndexMap& src) { |
no test coverage detected