< 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:263_26948838820

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
 929    public TurnCostFactorCache()
 9210    {
 9211        _cache = new TurnCostFactor?[1024];
 9212    }
 13
 14    public TurnCostFactor? Get(uint typeId)
 1917815    {
 1917816        return _cache.Length <= typeId ? null : _cache[typeId];
 1917817    }
 18
 19    public void Set(uint typeId, TurnCostFactor factor)
 5620    {
 5621        var cache = _cache;
 5622        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
 5638        cache[typeId] = factor;
 5639    }
 40}

Methods/Properties

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