return null;
}
if (size == 0){
final SortConfiguration sortConfiguration = new SortConfiguration();
sortConfiguration.useReplacementSelection(2, 2);
return (E) new DBMergeSortedSet(sortConfiguration, comparator, null);
}
final Class type = Registration.deserializeId(this)[0];
final SortedSet ms;
if (size < memoryLimit) {
if (type == Triple.class) {
ms = new TreeSet<Triple>(comparator);
} else {
ms = new TreeSet(comparator);
}
} else {
final SortConfiguration sortConfiguration = new SortConfiguration();
sortConfiguration.useReplacementSelection(2, 2);
if (type == Triple.class) {
ms = new DBMergeSortedSet(sortConfiguration, comparator, Triple.class);
} else {
ms = new DBMergeSortedSet(sortConfiguration, comparator, null);
}
}
for (int i = 0; i < size; i++) {
try {
ms.add(Registration.deserializeWithoutId(type, this));