Вопрос

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();
Это было полезно?

Решение

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);

Другие советы

"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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top