< Summary

Class:Itinero.Routing.Costs.Caches.TurnCostFactorCache
Assembly:Itinero
File(s):/home/runner/work/routing2/routing2/src/Itinero/Routing/Costs/Caches/TurnCostFactorCache.cs
Covered lines:12
Uncovered lines:11
Coverable lines:23
Total lines:40
Line coverage:52.1% (12 of 23)
Covered branches:2
Total branches:6
Branch coverage:33.3% (2 of 6)
Tag:251_23667616543

Metrics

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

File(s)

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

#LineLine coverage
 1using Itinero.Profiles;
 2
 3namespace Itinero.Routing.Costs.Caches;
 4
 5internal class TurnCostFactorCache
 6{
 7    private TurnCostFactor?[] _cache;
 8
 639    public TurnCostFactorCache()
 6310    {
 6311        _cache = new TurnCostFactor?[1024];
 6312    }
 13
 14    public TurnCostFactor? Get(uint typeId)
 202515    {
 202516        return _cache.Length <= typeId ? null : _cache[typeId];
 202517    }
 18
 19    public void Set(uint typeId, TurnCostFactor factor)
 2520    {
 2521        var cache = _cache;
 2522        if (cache.Length <= typeId)
 023        {
 024            var newSize = _cache.Length + 1024;
 025            while (newSize <= typeId)
 026            {
 027                newSize += 1024;
 028            }
 29
 030            var newCache = new TurnCostFactor?[newSize];
 031            cache.CopyTo(newCache, 0);
 32
 033            newCache[typeId] = factor;
 034            _cache = newCache;
 035            return;
 36        }
 37
 2538        cache[typeId] = factor;
 2539    }
 40}

Methods/Properties

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