Skip to content

Commit db8dd85

Browse files
committed
add more helpful helper method
1 parent 4afffb7 commit db8dd85

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

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
@@ -334,10 +334,22 @@ public int getIndex(long hashcode, int order) {
334334
public int[] getIndices(long hashcode, int... indices) {
335335
int[] ret = new int[indices.length];
336336
for (int i=0; i<ret.length; i++)
337-
ret[i] = getIndex(hashcode, i);
337+
ret[i] = getIndex(hashcode, indices[i]);
338338
return ret;
339339
}
340340

341+
/**
342+
* Retrieves an array of the indices.
343+
* @param hashcode
344+
* @param nindices
345+
* @return
346+
*/
347+
public int[] getIndices(long hashcode, int nindices) {
348+
int[] indices = new int[nindices];
349+
for (int i=0; i<nindices; i++) indices[i] = i;
350+
return getIndices(hashcode, indices);
351+
}
352+
341353
/**
342354
* Returns a formatted string representing all indices in the hash key.
343355
*

0 commit comments

Comments
 (0)