Collections java中集合子集和最小-最大元素集的理想集合类型

Collections java中集合子集和最小-最大元素集的理想集合类型,collections,hashmap,max,min,treemap,Collections,Hashmap,Max,Min,Treemap,我想使用java集合编写一段代码,该集合处理元素的子集(子范围)。我想找到具有最大值和最小值的元素集(键、值(自定义对象)) 基本上,我想要一个函数,它提供所选范围内最小值和最大值的子集(K,V)以供选择 结果元素将从原始集合中删除 public class mycol { int x; int y; mycol(int x, int y, int index){ this.x = x; this.y = y; } } TreeMap<Intege

我想使用java集合编写一段代码,该集合处理元素的子集(子范围)。我想找到具有最大值和最小值的元素集(键、值(自定义对象))

基本上,我想要一个函数,它提供所选范围内最小值和最大值的子集(K,V)以供选择

结果元素将从原始集合中删除

public class mycol {
int x;
int y;

mycol(int x, int y, int index){
        this.x = x;
        this.y = y;
    }
}
TreeMap<Integer, mycol> mycollection = new TreeMap<Integer, mycol>();

max_x_coll = mycollection.set_of_elements_with_max_x();//or a collection.max() function to do the same
//I then want to then again filter this set based on min/max values of y and then remove this element from the original list.
公共类mycol{
int x;
int-y;
mycol(整数x,整数y,整数索引){
这个.x=x;
这个。y=y;
}
}
TreeMap mycollection=新TreeMap();
max_x_coll=mycollection。使用_max_x()设置_元素的_//或者使用collection.max()函数执行相同的操作
//然后,我想再次根据y的最小/最大值筛选此集合,然后从原始列表中删除此元素。

在这种情况下,哪种集合类型最好具有(大多数,如果不是全部的话)内置功能,以便用最少的用户定义代码完成相同的操作。

为什么不使用TreeMap本身?树映射中的元素已经在树映射中进行了排序,我有以下{K,V}格式的值:{1,3},{2,4},{3,1},{4,4},{5,4}。我想要一组具有最大值的元素,即{2,4},{4,4},{5,4}。我能得到这个吗?