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

Popular posts from this blog

java - Incorrect order of records in M-M relationship in hibernate -

ruby - Net::HTTP extremely slow responses for HTTPS requests -

c++ - Boost Spirit Parser with a vector of three strings compiling into a struct, adapt not working -