Pergunta

Consider:

public List<Place> getAllInactivePlaces() {

    return this.placeDAO.findAllUnApprovedList();
}

The method I have shown above is to find all places. I need to convert Queue to get a FIFO.

Something like this:

Queue<Place>placeQueue = getAllInactivePlaces();
Foi útil?

Solução

Assuming that you currently have a list which is not a queue (like an ArrayList). Further assuming that you cannot pick a data structure appropriate to your use case to start with:

Queue<Place> queue = new LinkedList<>(yourList);

Outras dicas

"Achieve FIFO" is less a question of the data structure being used, but more about the code that puts in/pulls out data from that structure.

You need to update that calling code to work with the Queue interface instead of a List.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top