Fixed Duplicates in HashMap

This commit is contained in:
bly 2023-01-03 13:41:30 +01:00
parent 92e519e567
commit ccc19fac3e
2 changed files with 23 additions and 6 deletions

26
.idea/workspace.xml generated
View file

@ -4,8 +4,7 @@
<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="9b57ac51-c870-474b-9dfd-64a5fc490635" name="Changes" comment="Removing not needed lines"> <list default="true" id="9b57ac51-c870-474b-9dfd-64a5fc490635" name="Changes" comment="Fixed Duplicates in HashMap">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/ThreadedCompare.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/ThreadedCompare.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/ThreadedCompare.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/ThreadedCompare.java" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
@ -20,6 +19,17 @@
</list> </list>
</option> </option>
</component> </component>
<component name="Git.Rebase.Settings">
<option name="NEW_BASE" value="master" />
</component>
<component name="GithubPullRequestsUISettings">
<option name="selectedUrlAndAccountId">
<UrlAndAccount>
<option name="accountId" value="614b6e79-2a1d-40ca-82ec-6c7ae06c9284" />
<option name="url" value="https://github.com/bly-codes/Sherly.git" />
</UrlAndAccount>
</option>
</component>
<component name="MarkdownSettingsMigration"> <component name="MarkdownSettingsMigration">
<option name="stateVersion" value="1" /> <option name="stateVersion" value="1" />
</component> </component>
@ -79,7 +89,14 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1672704560597</updated> <updated>1672704560597</updated>
</task> </task>
<option name="localTasksCounter" value="6" /> <task id="LOCAL-00006" summary="Fixed Duplicates in HashMap">
<created>1672749481858</created>
<option name="number" value="00006" />
<option name="presentableId" value="LOCAL-00006" />
<option name="project" value="LOCAL" />
<updated>1672749481858</updated>
</task>
<option name="localTasksCounter" value="7" />
<servers /> <servers />
</component> </component>
<component name="Vcs.Log.Tabs.Properties"> <component name="Vcs.Log.Tabs.Properties">
@ -109,6 +126,7 @@
<MESSAGE value="First Creation" /> <MESSAGE value="First Creation" />
<MESSAGE value="Just a Test" /> <MESSAGE value="Just a Test" />
<MESSAGE value="Removing not needed lines" /> <MESSAGE value="Removing not needed lines" />
<option name="LAST_COMMIT_MESSAGE" value="Removing not needed lines" /> <MESSAGE value="Fixed Duplicates in HashMap" />
<option name="LAST_COMMIT_MESSAGE" value="Fixed Duplicates in HashMap" />
</component> </component>
</project> </project>

View file

@ -25,9 +25,8 @@ public class ThreadedCompare extends Thread {
bothList.add(file1); bothList.add(file1);
bothList.add(file2); bothList.add(file2);
//here it is trying to add the values in the HashMap //here it is trying to add the values in the HashMap so everything is nice and clear
Main.fileMap.putIfAbsent(getMD5Sum(file1.toFile()), bothList); Main.fileMap.putIfAbsent(getMD5Sum(file1.toFile()), bothList);
Main.fileMap.get(getMD5Sum(file1.toFile())).removeAll(bothList); Main.fileMap.get(getMD5Sum(file1.toFile())).removeAll(bothList);
Main.fileMap.get(getMD5Sum(file1.toFile())).addAll(bothList); Main.fileMap.get(getMD5Sum(file1.toFile())).addAll(bothList);