java - How to transpose element from Vector<HashMap<Integer,Double>>()? -
i have vector of hashmap...but want them transposed...first line put in column vector.. theese lines hashmaps in vector
matrix[ 0 ] = { (8.610482105102653,0 ), (9.551442421387952,1 ), (5.3757047978038734,2 ), } matrix[ 1 ] = { (4.465099271120103,0 ), (2.192818094857409,1 ), (6.135089039142705,2 ), } matrix[ 2 ] = { (8.308794639990024,0 ), (5.3010946979614495,1 ), (1.7648664328146066,2 ), }
i tried like:
public static vector<hashmap<integer, double>> transpose( vector<hashmap<integer, double>> m) { vector<hashmap<integer, double>> transpose = new vector<hashmap<integer, double>>(); hashmap<integer,double> h = new hashmap<integer,double>(); (int = 0; < m.size(); i++) { (map.entry<integer, double> entry : m.get(i).entryset()) { h=m.get(entry.getkey()); h.put(i,entry.getvalue()); system.out.println(" b"+h); //transpose.set(entry.getkey(), h); } } return transpose; }
but looks :
b{0=8.610482105102653, 1=9.551442421387952, 2=5.3757047978038734} b{0=9.551442421387952, 1=2.192818094857409, 2=6.135089039142705} b{0=5.3757047978038734, 1=5.3010946979614495, 2=1.7648664328146066} b{0=8.610482105102653, 1=9.551442421387952, 2=5.3757047978038734} b{0=9.551442421387952, 1=2.192818094857409, 2=6.135089039142705} b{0=5.3757047978038734, 1=6.135089039142705, 2=1.7648664328146066} b{0=8.610482105102653, 1=9.551442421387952, 2=5.3757047978038734} b{0=9.551442421387952, 1=2.192818094857409, 2=6.135089039142705} b{0=5.3757047978038734, 1=6.135089039142705, 2=1.7648664328146066}
thanks !
Comments
Post a Comment