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 0e6ce2e commit e40fb26
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 @@ -57,7 +58,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);
daoGeneticAlteration.deleteAllRecordsInGeneticProfile(this.geneticProfileId);
Expand Down

0 comments on commit e40fb26

Please sign in to comment.