// TODO: does not detect set type (hash/tree) when it's synchronized static Set cloneSet(Cl set) { if (set == null) ret new HashSet; synchronized(collectionMutex(set)) { Set s = similarEmptySet(set); s.addAll(set); ret s; } }