-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
96 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
src/main/java/io/github/meeples10/mcresourceanalyzer/Analysis.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
package io.github.meeples10.mcresourceanalyzer; | ||
|
||
import java.util.HashMap; | ||
import java.util.Hashtable; | ||
import java.util.Map; | ||
|
||
public class Analysis { | ||
public Map<String, Long> blocks = new HashMap<String, Long>(); | ||
public Map<String, HashMap<Integer, Long>> heights = new HashMap<String, HashMap<Integer, Long>>(); | ||
public Map<String, Long> blocks = new Hashtable<>(); | ||
public Map<String, Hashtable<Integer, Long>> heights = new Hashtable<>(); | ||
} |
40 changes: 38 additions & 2 deletions
40
src/main/java/io/github/meeples10/mcresourceanalyzer/AnalyzerThread.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,52 @@ | ||
package io.github.meeples10.mcresourceanalyzer; | ||
|
||
import java.util.HashSet; | ||
import java.util.Hashtable; | ||
import java.util.Set; | ||
|
||
public abstract class AnalyzerThread extends Thread { | ||
final RegionAnalyzer ra; | ||
final Region r; | ||
final Set<Analysis> analyses = new HashSet<>(); | ||
|
||
public AnalyzerThread(Region region) { | ||
public AnalyzerThread(RegionAnalyzer ra, Region region) { | ||
this.ra = ra; | ||
r = region; | ||
setName(r.name); | ||
} | ||
|
||
public abstract void run(); | ||
public void run() { | ||
process(); | ||
ra.add(combineAnalyses()); | ||
} | ||
|
||
public abstract void process(); | ||
|
||
private Analysis combineAnalyses() { | ||
Analysis out = new Analysis(); | ||
for(Analysis a : analyses) { | ||
for(String blockName : a.blocks.keySet()) { | ||
long count = a.blocks.get(blockName); | ||
if(out.blocks.containsKey(blockName)) { | ||
out.blocks.put(blockName, out.blocks.get(blockName) + count); | ||
} else { | ||
out.blocks.put(blockName, count); | ||
} | ||
} | ||
for(String blockName : a.heights.keySet()) { | ||
if(!out.heights.containsKey(blockName)) { | ||
out.heights.put(blockName, new Hashtable<Integer, Long>()); | ||
} | ||
for(int y : a.heights.get(blockName).keySet()) { | ||
long count = a.heights.get(blockName).get(y); | ||
if(out.heights.get(blockName).containsKey(y)) { | ||
out.heights.get(blockName).put(y, out.heights.get(blockName).get(y) + count); | ||
} else { | ||
out.heights.get(blockName).put(y, count); | ||
} | ||
} | ||
} | ||
} | ||
return out; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.