I have the next data:
for each post I have id-s that likes the post.
for example:
post: "Hi"
"12345"
"11111"
"22222"
"33333"
post: "bye"
"16666"
"77777"
"12345"
"33333"
etc
I defined the next variables:
Dictionary<string, LikesDistribution> IdsToLikesDistribution;
and the class
:
public class LikesDistribution {
public int counter;
public List<string> posts;
}
I want to count the total likes and the posts that each of the user likes.
for the above example:
"12345" 2 "Hi" "Bye"
"11111" 1 "Hi"
"22222" 1 "Hi"
"33333" 2 "Hi" "Bye"
"16666" 1 "Bye"
"77777" 1 "Bye"
if my dictionary was from Id to number of likes:
Dictionary<string, int> IdsToLikesDistribution;
I could do something like:
int value;
// if it doesn't exist
if (!IdsToLikesDistribution.TryGetValue(fanId, out value))
{
IdsToLikesDistribution.Add(fanId, 1);
}
// it exists so increase it by 1
else
{
IdsToLikesDistribution[fanId] = value + 1;
}
but now I don't know how to do it.
any help appreciated!