Fixed Duplicates in HashMap
This commit is contained in:
parent
529322e933
commit
075bd9511f
2 changed files with 26 additions and 23 deletions
27
.idea/workspace.xml
generated
27
.idea/workspace.xml
generated
|
@ -4,10 +4,9 @@
|
||||||
<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="Just a Test">
|
<list default="true" id="9b57ac51-c870-474b-9dfd-64a5fc490635" name="Changes" comment="Removing not needed lines">
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/ConsoleColors.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/ConsoleColors.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/ThreadedCompare.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/ThreadedCompare.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/Main.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Main.java" afterDir="false" />
|
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
|
@ -30,12 +29,12 @@
|
||||||
<option name="hideEmptyMiddlePackages" value="true" />
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
<option name="showLibraryContents" value="true" />
|
<option name="showLibraryContents" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PropertiesComponent"><![CDATA[{
|
<component name="PropertiesComponent">{
|
||||||
"keyToString": {
|
"keyToString": {
|
||||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true"
|
"RunOnceActivity.ShowReadmeOnStart": "true"
|
||||||
}
|
}
|
||||||
}]]></component>
|
}</component>
|
||||||
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
||||||
<component name="TaskManager">
|
<component name="TaskManager">
|
||||||
<task active="true" id="Default" summary="Default task">
|
<task active="true" id="Default" summary="Default task">
|
||||||
|
@ -73,7 +72,14 @@
|
||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1672703881482</updated>
|
<updated>1672703881482</updated>
|
||||||
</task>
|
</task>
|
||||||
<option name="localTasksCounter" value="5" />
|
<task id="LOCAL-00005" summary="Removing not needed lines">
|
||||||
|
<created>1672704560597</created>
|
||||||
|
<option name="number" value="00005" />
|
||||||
|
<option name="presentableId" value="LOCAL-00005" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1672704560597</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="6" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="Vcs.Log.Tabs.Properties">
|
<component name="Vcs.Log.Tabs.Properties">
|
||||||
|
@ -102,6 +108,7 @@
|
||||||
<component name="VcsManagerConfiguration">
|
<component name="VcsManagerConfiguration">
|
||||||
<MESSAGE value="First Creation" />
|
<MESSAGE value="First Creation" />
|
||||||
<MESSAGE value="Just a Test" />
|
<MESSAGE value="Just a Test" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value="Just a Test" />
|
<MESSAGE value="Removing not needed lines" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value="Removing not needed lines" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -20,21 +20,17 @@ public class ThreadedCompare extends Thread {
|
||||||
for (Path file2 : pathsToCompareTo) {
|
for (Path file2 : pathsToCompareTo) {
|
||||||
try {
|
try {
|
||||||
if (sameContent(file1, file2)) {
|
if (sameContent(file1, file2)) {
|
||||||
List<Path> bothPaths = new ArrayList<>();
|
List<Path> bothList = new ArrayList<>();
|
||||||
bothPaths.add(file1);
|
|
||||||
bothPaths.add(file2);
|
bothList.add(file1);
|
||||||
|
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
|
||||||
if (Main.fileMap.containsKey(getMD5Sum(file1.toFile()))) {
|
Main.fileMap.putIfAbsent(getMD5Sum(file1.toFile()), bothList);
|
||||||
if (!Main.fileMap.get(getMD5Sum(file1.toFile())).contains(file1)) {
|
|
||||||
Main.fileMap.get(getMD5Sum(file1.toFile())).add(file1);
|
Main.fileMap.get(getMD5Sum(file1.toFile())).removeAll(bothList);
|
||||||
}
|
Main.fileMap.get(getMD5Sum(file1.toFile())).addAll(bothList);
|
||||||
if (!Main.fileMap.get(getMD5Sum(file1.toFile())).contains(file2)) {
|
|
||||||
Main.fileMap.get(getMD5Sum(file1.toFile())).add(file2);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Main.fileMap.put(getMD5Sum(file1.toFile()), bothPaths);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
|
Reference in a new issue