Click to See Complete Forum and Search --> : TreeMap of Vector


mickey0
August 21st, 2009, 11:56 AM
Hello, my situation is this; I would like add element (integer that represent indexes in another Vector) in freqToIndex.Vector;

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,

Deliverance
August 21st, 2009, 01:01 PM
You have to retrieve the vector by the get method of the map which is referenced by an integer.


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


Vector<Integer> myVector = this.freqToIndex.get(rowToRetrieve);
myVector.add(_words.size() -1);