I was looking for the answer to this question about SO and Google, but have not yet found a suitable solution.
I am currently working on a LayerManager in the graph routing problem. The manager is responsible for providing and resetting a fixed set of layers.
I wanted to implement a Consumer-Producer pattern with a block list so that incoming routing requests were blocked, since there is still no free level. So far I have found a blocking queue , but since we donโt need FIFO, LIFO, but random access to the queue does not really work. To be more precise, something like this should be possible:
public Layer getLayer(){ for ( Layer layer : layers ) { if ( layer.isUnused() && layer.matches(request) ) return layers.pop(layer); } }
Is there any way to achieve this?
source share