< Summary

Class:Itinero.Data.GlobalEdgeIdSet
Assembly:Itinero
File(s):/home/runner/work/routing2/routing2/src/Itinero/Data/GlobalEdgeIdSet.cs
Covered lines:0
Uncovered lines:19
Coverable lines:19
Total lines:61
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/GlobalEdgeIdSet.cs

#LineLine coverage
 1using System;
 2using System.Collections;
 3using System.Collections.Generic;
 4using Itinero.Network;
 5
 6namespace Itinero.Data;
 7
 8/// <summary>
 9/// A default global id set for Guid ids.
 10/// </summary>
 11public sealed class GlobalEdgeIdSet : IEnumerable<(Guid globalId, EdgeId edgeId)>
 12{
 013    private readonly Dictionary<Guid, EdgeId> _set = new();
 14
 15    /// <summary>
 16    /// Sets a new mapping.
 17    /// </summary>
 18    /// <param name="globalEdgeId">The global edge id.</param>
 19    /// <param name="edgeId">The local edge id.</param>
 20    public void Set(Guid globalEdgeId, EdgeId edgeId)
 021    {
 022        _set[globalEdgeId] = edgeId;
 023    }
 24
 25    /// <summary>
 26    /// Removes a mapping.
 27    /// </summary>
 28    /// <param name="globalEdgeId">The global edge id.</param>
 29    public void Remove(Guid globalEdgeId)
 030    {
 031        _set.Remove(globalEdgeId);
 032    }
 33
 34    /// <summary>
 35    /// Gets a mapping if it exists.
 36    /// </summary>
 37    /// <param name="globalEdgeId">The global edge id.</param>
 38    /// <param name="edgeId">The edge associated with the given global edge, if any.</param>
 39    /// <returns>True if a mapping exists, false otherwise.</returns>
 40    public bool TryGet(Guid globalEdgeId, out EdgeId edgeId)
 041    {
 042        return _set.TryGetValue(globalEdgeId, out edgeId);
 043    }
 44
 45    /// <summary>
 46    /// Returns an enumerator that iterates through the collection.
 47    /// </summary>
 48    /// <returns>An enumerator that can be used to iterate through the collection.</returns>
 49    public IEnumerator<(Guid globalId, EdgeId edgeId)> GetEnumerator()
 050    {
 051        foreach (var (key, value) in _set)
 052        {
 053            yield return (key, value);
 054        }
 055    }
 56
 57    IEnumerator IEnumerable.GetEnumerator()
 058    {
 059        return this.GetEnumerator();
 060    }
 61}