Domanda

Hi I am doing a project where I load values into a tree set. The keys are times. The times are increasing(obviously:). After everything is loaded to the tree set I will go back and take out sample values at a specific interval (I dont know what the times will be, that is why I am using the tree so as to use the ceiling method) I also want to load all the points into a DB later.

My question is am I making it overcomplicated using the tree set as this is a red black tree it will be continually resizing as the keys are obviously sequential. But I am not sure of another data stucture that will allow me use the ceiling function

È stato utile?

Soluzione

I think this is the simplest option with the off-the-shelf options (in Java). From my quick research in Google's Guava I don't see anything that provides such methods, but if I was concerned about the insert performance I would build a layer around a priority queue.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top