src/ccutil/indexmapbidi.cpp
int IndexMap::SparseToCompact(int sparse_index) const {
  auto pos = std::upper_bound(compact_map_.begin(), compact_map_.end(), sparse_index);
  if (pos > compact_map_.begin()) {
    --pos;
  }
  auto result = pos - compact_map_.begin();
  return compact_map_[result] == sparse_index ? result : -1;
}
// 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.
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.
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 .
int IndexMap::SparseToCompact(int sparse_index) const {
  auto pos = std::upper_bound(compact_map_.begin(), compact_map_.end(), sparse_index);
  if (pos > compact_map_.begin()) {
    --pos;
  }
  auto result = pos - compact_map_.begin();
  return compact_map_[result] == sparse_index ? result : -1;
}
int IndexMap :: SparseToCompact ( int sparse_index ) const { auto pos = std :: upper_bound ( compact_map_ . begin ( ) , compact_map_ . end ( ) , sparse_index ) ; if ( pos > compact_map_ . begin ( ) ) { -- pos ; } auto result = pos - compact_map_ . begin ( ) ; return compact_map_ [ result ] == sparse_index ? result : -1 ; }
SparseToCompact takes a sparse index to an index in the compact space.
SparseToCompact takes a sparse index to an index in the compact space .