-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unmanagedPlatformDependentNativeDirectories (#60)
- Loading branch information
Showing
2 changed files
with
44 additions
and
2 deletions.
There are no files selected for viewing
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
27 changes: 27 additions & 0 deletions
27
plugin/src/main/scala/com/github/sbt/jni/util/CollectionOps.scala
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.github.sbt.jni | ||
package util | ||
|
||
import scala.collection.IterableLike | ||
import scala.collection.generic.CanBuildFrom | ||
import scala.language.implicitConversions | ||
|
||
class CollectionOps[A, Repr](xs: IterableLike[A, Repr]) { | ||
def distinctBy[B, That](f: A => B)(implicit cbf: CanBuildFrom[Repr, A, That]) = { | ||
val builder = cbf(xs.repr) | ||
val i = xs.iterator | ||
var set = Set[B]() | ||
while (i.hasNext) { | ||
val o = i.next | ||
val b = f(o) | ||
if (!set(b)) { | ||
set += b | ||
builder += o | ||
} | ||
} | ||
builder.result | ||
} | ||
} | ||
|
||
object CollectionOps { | ||
implicit def toCollectionOps[A, Repr](xs: IterableLike[A, Repr]) = new CollectionOps(xs) | ||
} |