![JAR search and dependency download from the Maven repository](/logo.png)
net.sourceforge.plantuml.nwdiag.next.NTetris Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of plantuml-mit Show documentation
Show all versions of plantuml-mit Show documentation
PlantUML is a component that allows to quickly write diagrams from text.
// THIS FILE HAS BEEN GENERATED BY A PREPROCESSOR.
package net.sourceforge.plantuml.nwdiag.next;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
public class NTetris {
private final Map all = new LinkedHashMap<>();
private final BooleanGrid grid = new BooleanGrid();
@Override
public String toString() {
return all.toString();
}
public void add(S element) {
int x = 0;
while (true) {
if (grid.isSpaceAvailable(element, x)) {
all.put(element, x);
grid.useSpace(element, x);
return;
}
x++;
if (x > 100)
throw new IllegalStateException();
}
}
public final Map getPositions() {
return Collections.unmodifiableMap(all);
}
public int getNWidth() {
int max = 0;
for (Entry ent : all.entrySet())
max = Math.max(max, ent.getValue() + ent.getKey().getNWidth());
return max;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy