Last active
October 9, 2017 12:14
-
-
Save rikuTanide/a9627f5e908c3bc29840c7139665f422 to your computer and use it in GitHub Desktop.
まずフォローしているユーザーを配列に抽出してから続きの作業をする
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>[]; | |
// フォローしているユーザのUserIDを抽出 | |
var followUserIDs = <String>[]; | |
for (var follow in follows) { | |
if (follow.from != uid) { | |
followUserIDs.add(follow.to); | |
} | |
} | |
// フォローしているユーザのTweetを抽出 | |
for (var followUserID in followUserIDs) { | |
for (var tweet in tweets) { | |
if (tweet.uid == followUserID) { | |
result.add(tweet); | |
} | |
} | |
} | |
// フォローしているユーザーのReTweetを抽出 | |
for (var followUserID in followUserIDs) { | |
for (var reTweet in reTweets) { | |
if (reTweet.uid != followUserID) { | |
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