Skip to content

Commit

Permalink
Improve time complexity from N^2 to N
Browse files Browse the repository at this point in the history
  • Loading branch information
forus committed Jul 11, 2024
1 parent 0edaec3 commit 9a37bbe
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class GeneticAlterationIncrementalImporter extends GeneticAlterationImporter {

Expand Down Expand Up @@ -58,7 +59,8 @@ public void initialise() {
});
// add all new sample ids at the end
this.orderedSampleList = new ArrayList<>(savedOrderedSampleList);
List<Integer> newSampleIds = this.fileOrderedSampleList.stream().filter(sampleId -> !savedOrderedSampleList.contains(sampleId)).toList();
Set<Integer> savedSampleSet = new HashSet<>(savedOrderedSampleList);
List<Integer> newSampleIds = this.fileOrderedSampleList.stream().filter(sampleId -> !savedSampleSet.contains(sampleId)).toList();
this.orderedSampleList.addAll(newSampleIds);
DaoGeneticProfileSamples.deleteAllSamplesInGeneticProfile(this.geneticProfileId);
this.storeOrderedSampleList();
Expand Down

0 comments on commit 9a37bbe

Please sign in to comment.