org.tron.p2p.utils.CollectionUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of libp2p Show documentation
Show all versions of libp2p Show documentation
libp2p is a p2p network SDK implemented in java language.
The newest version!
package org.tron.p2p.utils;
import java.util.ArrayList;
import java.util.List;
public class CollectionUtils {
public static List truncate(List items, int limit) {
if (limit > items.size()) {
return new ArrayList<>(items);
}
List truncated = new ArrayList<>(limit);
for (T item : items) {
truncated.add(item);
if (truncated.size() == limit) {
break;
}
}
return truncated;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy