mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-01-20 09:17:29 +07:00
Added support for retrieving first entry of a stat regardless of params
This commit is contained in:
parent
03503a8f79
commit
251a691bd5
@ -365,6 +365,17 @@ public final class StatList {
|
||||
return indexOf(list, stat, 0);
|
||||
}
|
||||
|
||||
int firstIndexOf(int list, short stat) {
|
||||
final int listStart = startingOffset(list);
|
||||
final int listEnd = endingOffset(list);
|
||||
final int index = Arrays.binarySearch(ids, listStart, listEnd, stat);
|
||||
if (index >= 0) {
|
||||
return firstIndexOf(stat, index, listStart);
|
||||
} else {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
private int firstIndexOf(final short stat, final int startIndex, final int listStart) {
|
||||
int i = startIndex - 1;
|
||||
final short[] ids = this.ids;
|
||||
|
@ -32,6 +32,13 @@ public final class StatListGetter {
|
||||
return tuple.set(stats, index);
|
||||
}
|
||||
|
||||
/** @see StatList#firstIndexOf(int, short) */
|
||||
StatGetter first(short stat) {
|
||||
final int index = stats.firstIndexOf(list, stat);
|
||||
if (index < 0) return null;
|
||||
return tuple.set(stats, index);
|
||||
}
|
||||
|
||||
public void addAll(StatListGetter src) {
|
||||
stats.addAll(list, src.stats, src.list);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user