TreeSet

去重(unique)

["222","111",'33','44','44'].unique()
=> ["222","111",'33','44']

这里用TreeSet可以将它实现

def unique = { List list->
    TreeSet set = new TreeSet()
    set.addAll(list)
    return set.toList()
}

其中TreeSet内部addAll通过for循环调用treeMap实现

list.each{e->
    //If the map previously contained a mapping for the key, the old value is replaced.
    treeMap.put(e, PRESENT)
}