Skip to content

Instantly share code, notes, and snippets.

@rikuTanide
Last active October 9, 2017 12:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rikuTanide/387a1414b73ab7f0ca5e7bd853f14518 to your computer and use it in GitHub Desktop.
Save rikuTanide/387a1414b73ab7f0ca5e7bd853f14518 to your computer and use it in GitHub Desktop.
一つのFor文で全部やる
/// followは全ユーザのフォロー・フォロワーの関係が入っているリスト
List<Tweet> tweets(String uid, List<Follow> follows, List<Tweet> tweets,
List<ReTweet>reTweets) {
var result = <Tweet>[];
for (var follow in follows) {
// 自分がフォローしている人だけを通す
if (follow.from != uid) {
continue;
}
// フォローしているユーザのTweetを抽出
for (var tweet in tweets) {
if (tweet.uid == follow.to) {
result.add(tweet);
}
}
// フォローしているユーザーのReTweetを抽出
for (var reTweet in reTweets) {
if (reTweet.uid != follow.to) {
continue;
}
for (var tweet in tweets) {
if (reTweet.tweetID == tweet.tweetID) {
result.add(tweet);
break;
}
}
}
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment