Last active
October 9, 2017 12:16
-
-
Save rikuTanide/387a1414b73ab7f0ca5e7bd853f14518 to your computer and use it in GitHub Desktop.
一つの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>[]; | |
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