Implement attributing locking when reforging

This commit is contained in:
Melledy
2025-11-17 03:11:12 -08:00
parent db6c3a5b0f
commit a18b7e8a2a
3 changed files with 87 additions and 10 deletions

View File

@@ -0,0 +1,46 @@
package emu.nebula.util;
import it.unimi.dsi.fastutil.ints.IntArrayList;
public class CustomIntArray extends IntArrayList {
private static final long serialVersionUID = -3887905394107667439L;
public CustomIntArray() {
super();
}
public void add(int index, int value) {
while (index > this.size()) {
super.add(0);
}
super.add(index, value);
}
@Override
public boolean add(int value) {
for (int i = 0; i < this.size(); i++) {
if (this.getInt(i) == 0) {
this.set(i, value);
return true;
}
}
return super.add(value);
}
/**
* Returns the amount of non-zero values in this array
*/
public int getValueCount() {
int realSize = 0;
for (int i = 0; i < super.size(); i++) {
if (this.getInt(i) != 0) {
realSize++;
}
}
return realSize;
}
}