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();
Was it helpful?

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

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top