indexof - Looping through a LinkedHashSet using indexes in Scala -


i have linkedhashset created seq. used linkedhashset because need keep order of seq, ensure uniqueness, set. need check linkedhashset against sequence verify various properties within them same. assumed loop through using index, i, appears not. here example of accomplish.

var s: seq[int] = { 1 myseq.size } return s.forall { =>    mylhs.indexof(i).something == myseq.indexof(i).something &&   mylhs.indexof(i).somethingelse == myseq.indexof(i).somethingelse  } 

so how access individual elements of lhs?

consider using zip method on collections create collection of pairs (tuples). specifics of depend on specifics. may want myseq.zip(mylhs) or mylhs.zip(myseq), create different structures. want myseq.zip(mylhs), i'm guessing. also, if collections large, may want take view first, e.g. myseq.view.zip(mylhs) pair collection non-strict.

once have combined collection, can use for-comprehension (or directly, myzip.foreach) traverse it.


Comments

Popular posts from this blog

How to run C# code using mono without Xamarin in Android? -

html - grunt SVG to webfont -

c# - SharpSsh Command Execution -