Do you need to structure your data like that?
There are several things to consider:
- For each value of ccc is there only one associated value X?
- Is the order of items in the Vector important here?
- Is the content of the data structure static, i.e. are you adding data to the structure during program execution, or is it write-once at start up?
- Are you removing data from the structure.
If associated values are unique, you could hold the data in a single Hashtable with the ccc values as keys, then retrieval of a value for a specific key is trivial. If the order of keys is important you could maintain a separate Vector of keys.
Otherwise you would have to iterate over the Vector, retrieve the value from each Hashtable for the ccc key, if that matches your search value, retrieve the value for the X key as your result. Something like this:
for ( int i = 0; i < locations.size( ); i++ ) {
Hashtable ht = (Hashtable) locations.elementAt( i );
if ( key.equals( ht.get( "ccc" ) ) ) {
System.out.println( "Value for key " + key + "=" + ht.get( "X" ) );
}
}