小编Loc*_*oci的帖子

我可以通过链接共享我的私人GitHub存储库吗?

我在GitHub上的私有存储库中有一个Java应用程序,我想与没有帐户的人共享它.我没有在网站上找到任何选项.

有没有办法做到这一点?协作者只能是GitHub用户.

git github

34
推荐指数
4
解决办法
3万
查看次数

在集合中查找单个对象,HashMap vs List过滤器

Customer从我读过的文件中生成一个列表.我将这些客户存储HashMap在密钥是唯一ID的位置:

Map<String, Customer> customers = readCustomers(); //For each object created customers.put(c.getCustomerId(), c);

从第二个文件中我获取了用于更新对象的数据HashMap.我使用密钥来查找要更新的对象:

//get the details informations customers.get(customerId).setDetails(details);

在java 8中我可以使用:

class Customer{
    ... 

    public static Customer find(List<Customer> customers, int id) {
        return customers.stream().filter(c -> c.customerId == id).findAny().get();
    }
}

//usage
List<Customer> customers = readCustomers();    
...
Customer.find(customers, 21).setDetails(details);
Run Code Online (Sandbox Code Playgroud)

使用Java 8方法会有性能提升吗?这些方法之间的最佳实践是什么?

java java-8 java-stream

7
推荐指数
1
解决办法
1281
查看次数

标签 统计

git ×1

github ×1

java ×1

java-8 ×1

java-stream ×1