Adding element at the middle of scala.collection.immutable.Vector in Java -



Adding element at the middle of scala.collection.immutable.Vector in Java -

i trying utilize scala's immutable.vector in java. can post simple java code this?

this have tried till now.

tried vector builder. tried vector.concat(seq<traversable <a>>)

here sample of have tried:

vector<long> part1= orignal.slice(0, indexofmid); vector<long> part2 = orignal.slice(indexofmid, orignal.size()); orignal= part2.appendfront(1l); vector <traversable<long>> vectoroftraversables = vector.empty(); vectoroftraversables.appendfront(orignal.totraversable()); vectoroftraversables.appendfront(part1.totraversable()); orignal= vector.concat(vectoroftraversables.toseq());

i getting next error

exception in thread "main" java.lang.nosuchmethoderror: scala.collection.immutable.vector.concat(lscala/collection/seq;)lscala/collection/immutable/vector;

is there improve totally different way this? or going wrong somewhere?

this should work:

vector<long> part1 = original.slice(0, indexofmid); vector<long> part2 = original.slice(indexofmid, original.size()); vectorbuilder<long> builder = new vectorbuilder<long>(); builder.$plus$plus$eq(part1); builder.$plus$eq(new long(100)); builder.$plus$plus$eq(part2); vector<long> result = builder.result();

vectorbuilder provides methods not utilize canbuildfrom or repeated parameters, it's much easier utilize java.

by way nosuchmethoderror due fact concat method of companion object. import scala.collection.immutable.vector$ , seek this:

vector$.module$.concat(vectoroftraversables.toseq());

java scala vector insert

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -