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

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -