2

i did search for information on this, but unfortunately couldnt find one .. Can anyone help with this ?

Example :

        URL feed = new URL(feedUrl);
        SyndFeedInput input = new SyndFeedInput();
        SyndFeed feedAllData = input.build(new XmlReader(feed));
        List<SyndEntry> data =  feedAllData.getEntries();

Does the List object "data" always contain the feed entries in the order that the feed published (i.e. the latest feed first and the rest in descending order of published date) ?

the outputs i got do list it in that order but im not a 100% sure whether its dependable and i can forgo the sorting excess.

4

1 回答 1

0

如果您需要对结果进行排序,那么每次排序都是可行的方法。如果碰巧结果列表已经排序,排序将非常快 O(n),因为它实际上并没有做任何工作,如果它需要排序,你就会被覆盖

正如其他人所说,如果可能的话,查看源总是一个好主意,但是如果将来依赖行为发生变化,强制自己对其进行排序可以保护你。

于 2012-03-19T21:18:44.573 回答