Java Array Shift shiftEnum(E current, E[] values, int delta)

Here you can find the source of shiftEnum(E current, E[] values, int delta)

Description

shift Enum

License

LGPL

Declaration

public static <E extends Enum> E shiftEnum(E current, E[] values, int delta) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

public class Main {
    public static <E extends Enum> E shiftEnum(E current, E[] values, int delta) {
        int next = current.ordinal() + delta;
        if (next < 0) {
            return values[(values.length - 1)];
        }/*from w  w w. j  ava 2  s  . co  m*/
        if (next >= values.length) {
            return values[0];
        }
        return values[next];
    }
}

Related

  1. shiftArgs(String[] args, int offset)
  2. shiftArray(String[] args, int shift)
  3. shiftArray(String[] array, int offset)
  4. ShiftAwayTrailingZerosTwoElements(int[] arr)
  5. shiftChroma(float[] chroma, int step)
  6. shiftLeft(byte[] array)
  7. shiftLeft(byte[] b1, int bytes)
  8. shiftLeft(byte[] block, byte[] output)
  9. shiftLeft(byte[] data, int shiftBy)