net.onedaybeard.ecs.model.MatrixData Maven / Gradle / Ivy
package net.onedaybeard.ecs.model;
import java.util.*;
public class MatrixData {
final List componentColumns;
final List managerColumns;
final List systemColumns;
final List factoryColumns;
final Map managerIndexMap;
final Map systemIndexMap;
final Map factoryIndexMap;
MatrixData(List componentColumns, List typeMappings) {
this.componentColumns = new ArrayList(componentColumns);
managerColumns = new ArrayList();
systemColumns = new ArrayList();
factoryColumns = new ArrayList();
managerIndexMap = new HashMap();
systemIndexMap = new HashMap();
factoryIndexMap = new HashMap();
extractArtemisTypes(typeMappings);
}
private void extractArtemisTypes(List typeMappings) {
SortedSet referencedManagers = new TreeSet();
SortedSet referencedSystems = new TreeSet();
SortedSet referencedFactories = new TreeSet();
for (RowTypeMapping mapping : typeMappings) {
insert(referencedManagers, mapping.refManagers);
insert(referencedSystems, mapping.refSystems);
insert(referencedFactories, mapping.refFactories);
}
int nextColumnIndex = 0;
for (String manager : referencedManagers) {
managerIndexMap.put(manager, nextColumnIndex++);
}
nextColumnIndex = 0;
for (String system : referencedSystems) {
systemIndexMap.put(system, nextColumnIndex++);
}
nextColumnIndex = 0;
for (String factory : referencedFactories) {
factoryIndexMap.put(factory, nextColumnIndex++);
}
managerColumns.addAll(referencedManagers);
systemColumns.addAll(referencedSystems);
factoryColumns.addAll(referencedFactories);
}
private static void insert(SortedSet artemisSet, String[] referenced) {
for (String ref : referenced)
artemisSet.add(ref);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy