mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-09-09 10:19:41 +02:00
Return Collections (or sublcasses) instead of Iterators
This allows us to exploid Java 8 streams and Java 5 for-each loops. The returned Collections are usually unmodifiable. We decided against returning Iterable because this would mean determining the size in O(n) compared to Collection.size() which is often faster (e.g. O(1)).
This commit is contained in:
parent
6ea1d65e73
commit
4cff008708
31 changed files with 219 additions and 282 deletions
|
@ -93,13 +93,13 @@ information concerning a node named "http://jabber.org/protocol/muc#rooms": <br>
|
|||
ServiceDiscoveryManager.getInstanceFor(connection).setNodeInformationProvider(
|
||||
<font color="#0000FF">"http://jabber.org/protocol/muc#rooms"</font>,
|
||||
new NodeInformationProvider() {
|
||||
public Iterator getNodeItems() {
|
||||
public List getNodeItems() {
|
||||
ArrayList answer = new ArrayList();
|
||||
Iterator rooms = MultiUserChat.getJoinedRooms(connection);
|
||||
while (rooms.hasNext()) {
|
||||
answer.add(new DiscoverItems.Item((String)rooms.next()));
|
||||
}
|
||||
return answer.iterator();
|
||||
return answer;
|
||||
}
|
||||
});
|
||||
</pre>
|
||||
|
@ -233,4 +233,4 @@ In this example we can see how to publish new items: <br>
|
|||
</blockquote>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue