feat: add classement match system
This commit is contained in:
@@ -40,6 +40,14 @@ public class TreeModel {
|
||||
@JoinColumn(referencedColumnName = "id")
|
||||
TreeModel right;
|
||||
|
||||
public TreeModel(Long category, Integer level, MatchModel match) {
|
||||
this.category = category;
|
||||
this.level = level;
|
||||
this.match = match;
|
||||
this.left = null;
|
||||
this.right = null;
|
||||
}
|
||||
|
||||
public List<TreeModel> flat() {
|
||||
List<TreeModel> out = new ArrayList<>();
|
||||
this.flat(out);
|
||||
@@ -55,4 +63,44 @@ public class TreeModel {
|
||||
if (this.left != null)
|
||||
this.left.flat(out);
|
||||
}
|
||||
|
||||
public int death() {
|
||||
int dg = 0;
|
||||
int dd = 0;
|
||||
|
||||
if (this.right != null)
|
||||
dg = this.right.death();
|
||||
|
||||
if (this.left != null)
|
||||
dg = this.left.death();
|
||||
|
||||
return 1 + Math.max(dg, dd);
|
||||
}
|
||||
|
||||
public int getMaxChildrenAtDepth(int death, int current) {
|
||||
if (current == death)
|
||||
return 1;
|
||||
|
||||
int tmp = 0;
|
||||
if (this.right != null)
|
||||
tmp += this.right.getMaxChildrenAtDepth(death, current + 1);
|
||||
|
||||
if (this.left != null)
|
||||
tmp += this.left.getMaxChildrenAtDepth(death, current + 1);
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
public void getChildrenAtDepth (int death, int current, List<TreeModel> out) {
|
||||
if (current == death) {
|
||||
out.add(this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.right != null)
|
||||
this.right.getChildrenAtDepth(death, current + 1, out);
|
||||
|
||||
if (this.left != null)
|
||||
this.left.getChildrenAtDepth(death, current + 1, out);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user