SeqUtils.scala (39c59369af6e7d78fa72e13aae3735f1a6e98f5c) | SeqUtils.scala (e3da8bad334fc71ba0d72f0607e2e93245ddaece) |
---|---|
1package utils 2 3import chisel3._ 4import chisel3.util._ 5 6import scala.collection.mutable 7 8object SeqUtils { 9 /** 10 * @todo remove it when when xiangshan is updated to 2.13.11 11 */ 12 def distinctBy[A, B](seqLike: Seq[B])(f: B => A): Seq[B] = { 13 val seen = new mutable.HashSet[A]() 14 var res = Seq[B]() 15 val it = seqLike.iterator 16 while (it.hasNext) { | 1package utils 2 3import chisel3._ 4import chisel3.util._ 5 6import scala.collection.mutable 7 8object SeqUtils { 9 /** 10 * @todo remove it when when xiangshan is updated to 2.13.11 11 */ 12 def distinctBy[A, B](seqLike: Seq[B])(f: B => A): Seq[B] = { 13 val seen = new mutable.HashSet[A]() 14 var res = Seq[B]() 15 val it = seqLike.iterator 16 while (it.hasNext) { |
17 val next = it.next | 17 val next = it.next() |
18 if (seen.add(f(next))) { 19 res :+= next 20 } 21 } 22 res 23 } 24 25 type Seq2[+T] = Seq[Seq[T]] --- 16 unchanged lines hidden --- | 18 if (seen.add(f(next))) { 19 res :+= next 20 } 21 } 22 res 23 } 24 25 type Seq2[+T] = Seq[Seq[T]] --- 16 unchanged lines hidden --- |