有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何找到对象的上限值?

如何找到对象列表的上限值

比如说,

假设我有一个类ComputerProperties,它表示计算机的不同硬件属性,如cpuTypecpuArchitecturememorygpu等作为变量

现在这个类将是列表{},以表示不同游戏的各种需求

现在,假设给定GTA V和Minecraft游戏硬件需求,我将如何找到一个能够满足这两个需求的特定ComputerProperties

我不想使用传统的>=来查找能够满足所有需求的ComputerProperties,因为列表List<ComputerProperties>的大小可能趋于n。 用户作为输入给出的游戏硬件要求为>1,并趋于m

或者有没有其他解决方案可以更快地解决这个问题

感谢您的建议和见解

谢谢


共 (1) 个答案

  1. # 1 楼答案

    据我所知,你可能想做这样的事情:

    List<CpuType> cpuTypeList = new ArrayList<CpuType>();
    List<Memory> memoryList = new ArrayList<Memory>();
    // other properties 
    
    for (ComputerProperties properties : listOfProperties) {
        cpuTypeList.add(properties.getCpuType());
        memoryList.add(properties.getMemory());
        // other properties    
    }
    
    CpuType mostCriticalCpuType = Collections.max(cpuTypeList);
    Memory mostCriticalMemory = Collections.max(memoryList);
    // other properties