-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rewrote spawn condition handling
- Loading branch information
Showing
5 changed files
with
88 additions
and
34 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
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
32 changes: 32 additions & 0 deletions
32
common/src/main/java/traben/entity_texture_features/utils/EntityBooleanLRU.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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package traben.entity_texture_features.utils; | ||
|
||
import it.unimi.dsi.fastutil.objects.Object2BooleanLinkedOpenHashMap; | ||
|
||
import java.util.UUID; | ||
|
||
public class EntityBooleanLRU extends Object2BooleanLinkedOpenHashMap<UUID> { | ||
{ | ||
defaultReturnValue(false); | ||
} | ||
|
||
final int capacity; | ||
|
||
public EntityBooleanLRU(int capacity) { | ||
this.capacity = capacity; | ||
} | ||
|
||
public EntityBooleanLRU() { | ||
this.capacity = 2048; | ||
} | ||
|
||
@Override | ||
public boolean put(UUID uuid, boolean v) { | ||
if (size() >= capacity) { | ||
UUID lastKey = lastKey(); | ||
if (!lastKey.equals(uuid)) { | ||
removeBoolean(lastKey); | ||
} | ||
} | ||
return this.putAndMoveToFirst(uuid, v); | ||
} | ||
} |