Sha256: eff2f0c74b0e95365df9a5b791f6ca5a1f31a00d8d746d1145031f65e056e7b3
Contents?: true
Size: 732 Bytes
Versions: 318
Compression:
Stored size: 732 Bytes
Contents
import java.util.ArrayList; import java.util.Collections; import java.util.List; final class HandshakeCalculator { private static final int REVERSE_SIGNALS_BIT_POSITION = 4; List<Signal> calculateHandshake(final int number) { final List<Signal> result = new ArrayList<>(); for (final Signal signal : Signal.values()) { if (isBitSet(signal.ordinal(), number)) { result.add(signal); } } if (isBitSet(REVERSE_SIGNALS_BIT_POSITION, number)) { Collections.reverse(result); } return result; } private boolean isBitSet(final int position, final int number) { return ((number >> position) & 1) == 1; } }
Version data entries
318 entries across 318 versions & 1 rubygems