< Summary

Class:Itinero.Data.GlobalVertexIdSet
Assembly:Itinero
File(s):/home/runner/work/routing2/routing2/src/Itinero/Data/GlobalVertexIdSet.cs
Covered lines:0
Uncovered lines:19
Coverable lines:19
Total lines:60
Line coverage:0% (0 of 19)
Covered branches:0
Total branches:2
Branch coverage:0% (0 of 2)
Tag:224_14471318300

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
.ctor()100%10%
Set(...)100%10%
Remove(...)100%10%
TryGet(...)100%10%
GetEnumerator()0%20%
System.Collections.IEnumerable.GetEnumerator()100%10%

File(s)

/home/runner/work/routing2/routing2/src/Itinero/Data/GlobalVertexIdSet.cs

#LineLine coverage
 1using System.Collections;
 2using System.Collections.Generic;
 3using Itinero.Network;
 4
 5namespace Itinero.Data;
 6
 7/// <summary>
 8/// Abstract definition of a global id map for vertices.
 9/// </summary>
 10public sealed class GlobalVertexIdSet : IEnumerable<(long globalId, VertexId vertex)>
 11{
 012    private readonly Dictionary<long, VertexId> _set = new();
 13
 14    /// <summary>
 15    /// Sets a new mapping.
 16    /// </summary>
 17    /// <param name="globalVertexId">The global vertex id.</param>
 18    /// <param name="vertex">The local vertex.</param>
 19    public void Set(long globalVertexId, VertexId vertex)
 020    {
 021        _set[globalVertexId] = vertex;
 022    }
 23
 24    /// <summary>
 25    /// Removes a mapping.
 26    /// </summary>
 27    /// <param name="globalVertexId">The global vertex id.</param>
 28    public void Remove(long globalVertexId)
 029    {
 030        _set.Remove(globalVertexId);
 031    }
 32
 33    /// <summary>
 34    /// Gets a mapping if it exists.
 35    /// </summary>
 36    /// <param name="globalVertexId">The global vertex id.</param>
 37    /// <param name="vertex">The vertex associated with the given global vertex, if any.</param>
 38    /// <returns>True if a mapping exists, false otherwise.</returns>
 39    public bool TryGet(long globalVertexId, out VertexId vertex)
 040    {
 041        return _set.TryGetValue(globalVertexId, out vertex);
 042    }
 43
 44    /// <summary>
 45    /// Returns an enumerator that iterates through the collection.
 46    /// </summary>
 47    /// <returns>An enumerator that can be used to iterate through the collection.</returns>
 48    public IEnumerator<(long globalId, VertexId vertex)> GetEnumerator()
 049    {
 050        foreach (var (key, value) in _set)
 051        {
 052            yield return (key, value);
 053        }
 054    }
 55
 56    IEnumerator IEnumerable.GetEnumerator()
 057    {
 058        return this.GetEnumerator();
 059    }
 60}