use union/diff operator on Sets (optimization)

This commit is contained in:
Roland Kuhn 2016-03-18 12:28:07 +01:00
parent b7fecaff37
commit 777a400b12
6 changed files with 15 additions and 18 deletions

View file

@ -19,7 +19,7 @@ case class TwoPhaseSet(
def remove(element: String): TwoPhaseSet =
copy(removals = removals.add(element))
def elements: Set[String] = adds.elements -- removals.elements
def elements: Set[String] = adds.elements diff removals.elements
override def merge(that: TwoPhaseSet): TwoPhaseSet =
copy(

View file

@ -32,8 +32,7 @@ object TwitterStreamQuickstartDocSpec {
//#model
//#tweet-source
val tweets: Source[Tweet, NotUsed]
//#tweet-source
val tweets: Source[Tweet, NotUsed] //#tweet-source
= Source(
Tweet(Author("rolandkuhn"), System.currentTimeMillis, "#akka rocks!") ::
Tweet(Author("patriknw"), System.currentTimeMillis, "#akka !") ::