Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLev Dragunov <l.dragunov@corp.mail.ru>2015-02-27 10:48:29 +0300
committerAlex Zolotarev <alex@maps.me>2015-09-23 02:38:22 +0300
commit07feabd91008db106e3a8057709309894945b295 (patch)
tree23d80aa17c0107400da999990155d0e6e99cfbf0 /indexer/features_offsets_table.cpp
parent47a9725c116804c6238fb530cc523efb37e14a5a (diff)
Feature offset table backward search method
Diffstat (limited to 'indexer/features_offsets_table.cpp')
-rw-r--r--indexer/features_offsets_table.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/indexer/features_offsets_table.cpp b/indexer/features_offsets_table.cpp
index fa524ab6e9..c39a691834 100644
--- a/indexer/features_offsets_table.cpp
+++ b/indexer/features_offsets_table.cpp
@@ -90,4 +90,29 @@ namespace feature
ASSERT_LESS(index, size(), ("Index out of bounds", index, size()));
return m_table.select(index);
}
+
+ size_t FeaturesOffsetsTable::GetFeatureIndexbyOffset(uint64_t offset) const
+ {
+ ASSERT_LESS_OR_EQUAL(offset, m_table.select(size() - 1), ("Offset out of bounds", offset,
+ m_table.select(size() - 1)));
+
+ //Binary search in elias_fano list
+ size_t first = 0, last = size();
+ size_t count = last - first, step, current;
+ while (count > 0)
+ {
+ step = count / 2;
+ current = first + step;
+ if (m_table.select(current) < offset)
+ {
+ first = ++current;
+ count -= step + 1;
+ }
+ else
+ count = step;
+ }
+ return current;
+
+ }
+
} // namespace feature