LCOV - code coverage report
Current view: top level - src/foreign/RoutingKit/include/routingkit - id_mapper.h (source / functions) Coverage Total Hit
Test: lcov.info Lines: 85.7 % 7 6
Test Date: 2026-09-23 15:43:02 Functions: - 0 0

            Line data    Source code
       1              : #ifndef ROUTING_KIT_ID_MAPPER_H
       2              : #define ROUTING_KIT_ID_MAPPER_H
       3              : 
       4              : #include <routingkit/constants.h>
       5              : 
       6              : #include <stdint.h>
       7              : #include <assert.h>
       8              : #include <stdexcept>
       9              : #include <vector>
      10              : #include <algorithm>
      11              : 
      12              : namespace RoutingKit{
      13              : 
      14         6353 : class LocalIDMapper{
      15              : public:
      16         1698 :         LocalIDMapper():bit_count_(0){}
      17              :         template<class Vec>
      18         6353 :         explicit LocalIDMapper(const Vec&vec):
      19         6353 :                 LocalIDMapper(vec.size(), vec.data()){}
      20              :         LocalIDMapper(uint64_t bit_count_, const uint64_t*bits_);
      21              : 
      22              :         uint64_t global_id_count()const{
      23            0 :                 return bit_count_;
      24              :         }
      25              : 
      26              :         uint64_t local_id_count()const{
      27         6792 :                 if(!rank_.empty())
      28         6792 :                         return rank_.back();
      29              :                 else
      30              :                         return 0;
      31              :         }
      32              : 
      33              :         bool is_global_id_mapped(uint64_t global_id) const{
      34              :                 assert(global_id < global_id_count());
      35              :                 return (bits_[global_id / 64] & (1ull << (global_id % 64))) != 0;
      36              :         }
      37              : 
      38              :         uint64_t to_local(uint64_t global_id) const;
      39              :         uint64_t to_local(uint64_t global_id, uint64_t invalid) const;
      40              : 
      41              :         uint64_t memory_overhead_in_bits()const{return rank_.size()*64;}
      42              : protected:
      43              :         const uint64_t*bits_;
      44              :         uint64_t bit_count_;
      45              :         std::vector<uint64_t>rank_;
      46              : };
      47              : 
      48              : class IDMapper : public LocalIDMapper{
      49              : public:
      50              :         IDMapper(){}
      51              :         template<class Vec>
      52              :         explicit IDMapper(const Vec&vec):
      53              :                 IDMapper(vec.size(), vec.data()){}
      54              :         IDMapper(uint64_t bit_count_, const uint64_t*bits_);
      55              : 
      56              :         uint64_t to_global(uint64_t local_id) const;
      57              : 
      58              :         uint64_t memory_overhead_in_bits()const{return LocalIDMapper::memory_overhead_in_bits() + select_.size()*64;}
      59              : private:
      60              :         std::vector<uint64_t>select_;
      61              : };
      62              : 
      63              : } // RoutingKit
      64              : 
      65              : #endif
        

Generated by: LCOV version 2.0-1