二つのFor文に分ける
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// followは全ユーザのフォロー・フォロワーの関係が入っているリスト | |
List<Tweet> tweets(String uid, List<Follow> follows, List<Tweet> tweets, | |
List<ReTweet>reTweets) { | |
var result = <Tweet>[]; | |
// フォローしているユーザのTweetを抽出 | |
for (var follow in follows) { | |
// 自分がフォローしている人だけを通す | |
if (follow.from != uid) { | |
continue; | |
} | |
for (var tweet in tweets) { | |
if (tweet.uid == follow.to) { | |
result.add(tweet); | |
} | |
} | |
} | |
// フォローしているユーザーのReTweetを抽出 | |
for (var follow in follows) { | |
// 自分がフォローしている人だけを通す | |
if (follow.from != uid) { | |
continue; | |
} | |
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