dictionary - Java data structure to allow boolean flags on objects and sorting? -
i wish have set of objects , booleans mark object "visited" or not. naturally thought of map tell me if object visited or not. want them sorted too, whenever ask "who 'smallest' object visited?". calculation wouldn't difficult, max o(n) on data structure. in specific case i'm asking date object, it's irrelevant. objects can added data structure @ moment, , entered 'false' values.
use sortedset
. when object visited, add set. find out if object visited, use set.contains()
. find smallest object:
t smallest = set.isempty() ? null : set.iterator().next();
Comments
Post a Comment