< 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:4
Uncovered lines:19
Coverable lines:23
Total lines:40
Line coverage:17.3% (4 of 23)
Covered branches:0
Total branches:6
Branch coverage:0% (0 of 6)
Tag:224_14471318300

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
.ctor()100%1100%
Get(...)0%20%
Set(...)0%40%

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
 269    public TurnCostFactorCache()
 2610    {
 2611        _cache = new TurnCostFactor?[1024];
 2612    }
 13
 14    public TurnCostFactor? Get(uint typeId)
 015    {
 016        return _cache.Length <= typeId ? null : _cache[typeId];
 017    }
 18
 19    public void Set(uint typeId, TurnCostFactor factor)
 020    {
 021        var cache = _cache;
 022        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
 038        cache[typeId] = factor;
 039    }
 40}

Methods/Properties

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