Exemplo n.º 1
0
 static void Add(LinkedListDictionary <int, List <Edge <T> > > edges, Edge <T> edge)
 {
     if (edges.TryGetValue(edge.BoundaryEdgeNumber, out List <Edge <T> > boundary))
     {
         boundary.Add(edge);
     }
     else
     {
         List <Edge <T> > newBoundary = new List <Edge <T> >();
         newBoundary.Add(edge);
         edges.Add(edge.BoundaryEdgeNumber, newBoundary);
     }
 }
Exemplo n.º 2
0
        static IDictionary <int, int> ExtractPeriodicBoundaryMap(byte[] tags)
        {
            IDictionary <int, int>  periodicBoundaryMap = new Dictionary <int, int>();
            IDictionary <byte, int> usedTags            = new LinkedListDictionary <byte, int>();

            for (int i = 0; i < tags.Length; ++i)
            {
                byte tag = tags[i];
                if (tag >= GridCommons.FIRST_PERIODIC_BC_TAG && tag < 255)
                {
                    if (usedTags.TryGetValue(tag, out int index))
                    {
                        periodicBoundaryMap.Add(i, index);
                        periodicBoundaryMap.Add(index, i);
                    }
                    else
                    {
                        usedTags.Add(tag, i);
                    };
                }
            }
            return(periodicBoundaryMap);
        }