diff options
author | vng <viktor.govako@gmail.com> | 2014-11-04 19:01:53 +0300 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:32:14 +0300 |
commit | 7805af6881fa0c6582ae811c5b477d505ce8d65b (patch) | |
tree | bbac4bb90b48535db310154f5e596de23d939d5b /indexer/scale_index.hpp | |
parent | 6291aab69594feca72f849a5b0625b882af860fe (diff) |
Minor refactoring.
Diffstat (limited to 'indexer/scale_index.hpp')
-rw-r--r-- | indexer/scale_index.hpp | 46 |
1 files changed, 5 insertions, 41 deletions
diff --git a/indexer/scale_index.hpp b/indexer/scale_index.hpp index 5bcce41d1c..1c671010eb 100644 --- a/indexer/scale_index.hpp +++ b/indexer/scale_index.hpp @@ -5,56 +5,20 @@ #include "../coding/var_serial_vector.hpp" -#include "../base/assert.hpp" -#include "../base/base.hpp" -#include "../base/macros.hpp" #include "../base/stl_add.hpp" #include "../std/algorithm.hpp" #include "../std/bind.hpp" +/// Index bucket <--> Draw scale range. class ScaleIndexBase { public: - enum { NUM_BUCKETS = 18 }; - - ScaleIndexBase() - { -#ifdef DEBUG - for (size_t i = 0; i < ARRAY_SIZE(kScaleBuckets); ++i) - { - ASSERT_LESS(kScaleBuckets[i], static_cast<uint32_t>(NUM_BUCKETS), (i)); - ASSERT(i == 0 || kScaleBuckets[i] >= kScaleBuckets[i-1], - (i, kScaleBuckets[i-1], kScaleBuckets[i])); - } -#endif - } - - static uint32_t BucketByScale(uint32_t scale) - { - ASSERT_LESS(scale, ARRAY_SIZE(kScaleBuckets), ()); - return scale >= ARRAY_SIZE(kScaleBuckets) ? NUM_BUCKETS - 1 : kScaleBuckets[scale]; - } - - static pair<uint32_t, uint32_t> ScaleRangeForBucket(uint32_t bucket) - { - // TODO: Cache ScaleRangeForBucket in class member? - ASSERT_LESS(bucket, static_cast<uint32_t>(NUM_BUCKETS), ()); - pair<uint32_t, uint32_t> res(ARRAY_SIZE(kScaleBuckets), 0); - for (uint32_t i = 0; i < ARRAY_SIZE(kScaleBuckets); ++i) - { - if (kScaleBuckets[i] == bucket) - { - res.first = min(res.first, i); - res.second = max(res.second, i + 1); - } - } - return res; - } - -private: - static uint32_t const kScaleBuckets[18]; + static uint32_t GetBucketsCount(); + static uint32_t BucketByScale(uint32_t scale); + /// @return Range like [x, y). + static pair<uint32_t, uint32_t> ScaleRangeForBucket(uint32_t bucket); }; template <class ReaderT> |