I have an instance variable _foo declared like so -
List< Dictionary<int, HashSet<int> > > _foo;
Yes, it is a messy data structure that is a List of Dictionaries whose key is an integer and its associated value is a HashSet of integers.
I am wondering whether a LINQ expression could be written that would do the equivalent of this code snippet:
var myList = new List<(int, int, int)>();
for (int xx = 0; xx < _foo.Count; ++xx)
foreach (var zzyy in _foo[xx])
if (zzyy.Value.Count == 1)
myList.Add((xx, zzyy.Value.First, zzyy.Key));
In other words, I would like to capture the indices of the elements in the List whose Dictionary-value (a HashSet) holds only a single value. Together with this index, I am also capturing the Dictionary-Key and the corresponding sole value within the Dictionary-value.
xx, I would not expect a Linq solution to be shorter or more readable than your current one.