Exemple #1
0
 /**
  * Reverse the order of the elements in the range of the list.
  *
  * @param from the inclusive index at which to start reversing
  * @param to the exclusive index at which to stop reversing
  */
 public LongSequence reverse(int from, int to) {
   if (from == to) {
     return this;
   }
   if (from > to) {
     throw new IllegalArgumentException("get cannot be greater than to");
   }
   for (int i = from, j = to - 1; i < j; i++, j--) {
     swap(i, j);
   }
   return this;
 }
Exemple #2
0
 /**
  * Shuffle the elements of the list using the specified random number generator.
  *
  * @param rand a <code>Random</code> value
  */
 public LongSequence shuffle(Random rand) {
   for (int i = pos; i-- > 1; ) {
     swap(i, rand.nextInt(i));
   }
   return this;
 }