Support both masks and arrays of indices.