Open
Description
where does the val list head :: rest
appear from in the following function ?
def groupSorted[K,S,V]( it : Iterator[((K, S), V)] ) : Iterator[(K, List[(S, V)])] = {
val res = List[ (K, ArrayBuffer[(S, V)]) ]()
it.foldLeft(res)(
(list, next) => list match {
case Nil => val ((firstKey, secondKey), value) = next
List((firstKey, ArrayBuffer((secondKey, value))))
case head :: rest =>
val (curKey, valueBuf) = head
val ((firstKey, secondKey), value) = next
if (!firstKey.equals(curKey) ) {
(firstKey, ArrayBuffer((secondKey, value))) :: list
} else {
valueBuf.append((secondKey, value))
list
}
}
).map { case (key, buf) => (key, buf.toList) }.iterator
}
Metadata
Metadata
Assignees
Labels
No labels