コード例 #1
0
 /// <summary>
 /// Sets all specified keys of the property map to the specified reset value.
 /// </summary>
 /// <param name="pmap">the property map</param>
 /// <param name="nodes">the elements whose property values are to be reset</param>
 /// <param name="value">reset value</param>
 public static void Reset <TThis, TValue>(this IPropMap <TThis, TValue> pmap,
                                          IEnumerable <TThis> nodes, TValue value)
 {
     pmap.RequireAccess(EAccess.WriteOnly);
     foreach (TThis node in nodes)
     {
         pmap[node] = value;
     }
 }
コード例 #2
0
 /// <summary>
 /// Inverts a property map-based relation.
 /// </summary>
 /// <param name="a">graph adapter providing temporary list storage</param>
 /// <param name="srcrel">source property map</param>
 /// <param name="dstrel">destination property map for inverted relation</param>
 /// <param name="nodes">nodes to be considered for the inversion</param>
 public static void InvertRelation <T>(this IGraphAdapter <T> a,
                                       IPropMap <T, T[]> srcrel, IPropMap <T, T[]> dstrel, IEnumerable <T> nodes)
 {
     a.CreateDefaultTempStorage(nodes);
     srcrel.RequireAccess(EAccess.ReadOnly);
     dstrel.RequireAccess(EAccess.WriteOnly);
     foreach (T node in nodes)
     {
         foreach (T adj in srcrel[node])
         {
             a.TempList[adj].Add(node);
         }
     }
     foreach (T node in nodes)
     {
         dstrel[node] = a.TempList[node].ToArray();
     }
     a.TempList.Clear(nodes);
 }