Joined February 2017
·

hutchinscruff

IT stuff
·
Cheshire
·
·

Posted to Scala week 3 over 1 year ago

Well, my experience is that changing the implementation of union round a bit made little difference, the performance was still appalling. I couldn't even construct the allTweets value it just took forever. The whole union thing maxed out with more than about 70 tweets.

However, this solution went like the wind:

def asList: List[Tweet] =
left.asList:::right.asList:::List(elem)

def union(that: TweetSet): TweetSet = {
TweetReader.toTweetSet(this.asList ::: that.asList ::: List(elem): List[Tweet])}

I.e. bung everything in Lists, concatenate the Lists and then reconstruct the resultant TweetSet from the concatenated List. Crude maybe, but effective. (the definition of asList for Empty is left to the reader)

Achievements
1 Karma
0 Total ProTip Views