-
TreeMap of Vector
Hello, my situation is this; I would like add element (integer that represent indexes in another Vector) in freqToIndex.Vector;
Code:
SortedMap <Integer, Vector< Integer> > freqToIndex= new TreeMap < Integer, Vector< Integer > >();
void foo() {
//_word is another vector
this.freqToIndex.put( totalFreq, freqToIndex.previuosVector.add (_words.size() -1 );
}
I don't undertand how to access to the Vector inside the TreeMap. This is my problem at moment...
Any help, please?
thanks,
-
Re: TreeMap of Vector
You have to retrieve the vector by the get method of the map which is referenced by an integer.
Code:
Integer rowToRetrieve = null;
/* set the rowToRetrieve for example */
/* This is my vector. so I can just method chain to act on it */
this.freqToIndex.get(rowToRetrieve).add(_words.size() -1);
Another way to look at it is
Code:
Vector<Integer> myVector = this.freqToIndex.get(rowToRetrieve);
myVector.add(_words.size() -1);