Convert a Java List of Lists to Scala without O(n) iteration? -


To do a good job while using Scala's Java converters to change a Java list in a Scala list, answer

Unfortunately, I need to change the list of scala type lists in Java, and this solution does not work:

  // pseudocode java.util.List [java. Use.List [String]]. SSKL - & gt; Is there a way to do this conversion without the O (n) repetition on Java Octa?  

  import scala.collection.JavaConverters._ val javaListOfLists = list (list ("one", "b", "c"). AsJava, list ("D", "E", "alternatively, you External list can convert a stream to a list [in the list] [T]], it will only apply the conversion cost, as you would each item Access  
  val ScalaStreamOfLists = javaListOfLists.asScala.toStream.map (_ as.Scala.toList)  

If you do not want to pay the conversion cost at all, then you have to go around java.util.List You can write cover which will give you a scala archive interface. It will be shot on a hard stack:

  def wrap [T] (Java eraterator: Java.Dilil.itator [T]): Stream [T] = {if (javaIterator.hasNext) javaIterator next # :: wrap (Java eraterator) other empty} Variant External Wrap = Wrap (Java ListFulistists. Director) .map (Internal => Wrap (Inner Nititator ()))  

Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -