문제

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