Simple Problem but tough for me if i want it in linear time
chrischia82 at gmail.com
Sun Aug 15 14:47:04 CEST 2010
dataList = [a, b, c, ...]
where a, b, c are objects of a Class X.
In Class X, it contains self.name and self.number
If i wish to test whether a number (let's say 100) appears in one of
the object, and return that object,
is that only fast way of solving this problem without iterating
through every object to see the number value?
dataList.__contains__ can only check my object instance name...
anyone can solve this in linear complexity?
More information about the Python-list