Skip to content

Commit e833c04

Browse files
committed
add hash-based accessor
1 parent 3b5f067 commit e833c04

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

common-tools/clas-utils/src/main/java/org/jlab/utils/groups/IndexedList.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,23 @@ public int getIndex(long hashcode, int order) {
326326
return (int) ((hashcode >> this.byteShifts[order]) & mask);
327327
}
328328

329+
/**
330+
* Retrieves an array of the requested indices.
331+
*
332+
* @param indices
333+
* @return
334+
*/
335+
public int[] getIndices(long hashcode, int... indices) {
336+
int[] ret = new int[indices.length];
337+
for (int i=0; i<ret.length; i++)
338+
ret[i] = getIndex(hashcode, i);
339+
return ret;
340+
}
341+
329342
/**
330343
* Returns a formatted string representing all indices in the hash key.
331344
*
332345
* @param hashcode the encoded long key
333-
* @param length the number of indices to extract
334346
* @return a string representation of the indices
335347
*/
336348
public String getString(long hashcode) {

0 commit comments

Comments
 (0)