Java implementation of a linear general selection algorithm