RunicBoard.GetRuneLinks C# (CSharp) Method

GetRuneLinks() public method

Creates a list containing every unique link between two runes placed on the board.
public GetRuneLinks ( ) : Element>>.List
return Element>>.List
    public List<KeyValuePair<Element, Element>> GetRuneLinks()
    {
        Dictionary<int, KeyValuePair<Element, Element>> dict = new Dictionary<int, KeyValuePair<Element, Element>>();
        foreach(int pos in _runesOnBoard.Keys)
        {
            List<int> neighbours = GetNeighboursPosition(pos);
            foreach(int idNeigh in neighbours)
            {
                int idLink = pos + idNeigh;
                if (!dict.ContainsKey(idLink))
                {
                    KeyValuePair<Element, Element> link = new KeyValuePair<Element, Element>(_runesOnBoard[pos].Element, _runesOnBoard[idNeigh].Element);
                    dict.Add(idLink, link);
                }
            }
        }

        List<KeyValuePair<Element, Element>> listLink = new List<KeyValuePair<Element, Element>>();
        foreach(int id in dict.Keys)
        {
            listLink.Add(dict[id]);
        }

        return listLink;
    }
}