Easy access to entries in set - using where conditions
The class structure is of the following format-
class A
{
Set<B> bHolder;
}
class B
{
Set<C> cHolder;
}
class C
{
String data;
}
Goal : To 开发者_如何学Pythonretrieve an entry from class A depending on the data in class C
Eg: get B from aObject.bHolder.cHolder.data = "compareString"
Is there any way to do it without completely through the sets?
Thx -Kiru
Not when you've just got sets, no. If you want to perform some sort of lookup, you need a collection which supports lookups, such as HashMap
(or a Map
in general).
精彩评论