Question

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();
Était-ce utile?

La solution

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

Autres conseils

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top