< Summary

Class:Itinero.Routing.Costs.Caches.EdgeFactorCache
Assembly:Itinero
File(s):/home/runner/work/routing2/routing2/src/Itinero/Routing/Costs/Caches/EdgeFactorCache.cs
Covered lines:13
Uncovered lines:13
Coverable lines:26
Total lines:45
Line coverage:50% (13 of 26)
Covered branches:2
Total branches:6
Branch coverage:33.3% (2 of 6)
Tag:224_14471318300

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
.ctor()100%1100%
Get(...)50%266.66%
Set(...)25%431.25%

File(s)

/home/runner/work/routing2/routing2/src/Itinero/Routing/Costs/Caches/EdgeFactorCache.cs

#LineLine coverage
 1using Itinero.Profiles;
 2
 3namespace Itinero.Routing.Costs.Caches;
 4
 5internal class EdgeFactorCache
 6{
 7    private EdgeFactor?[] _cache;
 8
 269    public EdgeFactorCache()
 2610    {
 2611        _cache = new EdgeFactor?[1024];
 2612    }
 13
 14    public EdgeFactor? Get(uint edgeTypeId)
 3615    {
 3616        if (_cache.Length <= edgeTypeId)
 017        {
 018            return null;
 19        }
 20
 3621        return _cache[edgeTypeId];
 3622    }
 23
 24    public void Set(uint edgeTypeId, EdgeFactor factor)
 2625    {
 2626        var cache = _cache;
 2627        if (cache.Length <= edgeTypeId)
 028        {
 029            var newSize = _cache.Length + 1024;
 030            while (newSize <= edgeTypeId)
 031            {
 032                newSize += 1024;
 033            }
 34
 035            var newCache = new EdgeFactor?[newSize];
 036            cache.CopyTo(newCache, 0);
 37
 038            newCache[edgeTypeId] = factor;
 039            _cache = newCache;
 040            return;
 41        }
 42
 2643        cache[edgeTypeId] = factor;
 2644    }
 45}

Methods/Properties

.ctor()
Get(...)
Set(...)