Discuss / Java / 只让你修改TODO啊,在别处改就不对了

只让你修改TODO啊,在别处改就不对了

Topic source

Joker.fu_95

#1 Created at ... [Delete] [Delete and Lock User]
static List<Message> process(List<Message> received) {
// TODO: 按sequence去除重复消息    Set<Message> set = new TreeSet<>(new Comparator<Message>() {
        @Override        public int compare(Message o1, Message o2) {
            return o1.sequence - o2.sequence;
        }
    });
    set.addAll(received);
    received.clear();
    received.addAll(set);
    return received;
}

o_0

#2 Created at ... [Delete] [Delete and Lock User]

代码有问题吧,received集合是用List.of()建立的,不能使用clear()清空。


  • 1

Reply