Here you can find the source of nextPermutation(int v)
v
, return next permutation
Parameter | Description |
---|---|
v | a parameter |
public static int nextPermutation(int v)
//package com.java2s; //License from project: Open Source License public class Main { /**/*ww w . jav a 2 s . co m*/ * Permutates the bits with value 1 in bitstring <code>v</code>, return next permutation * * @param v * @return */ public static int nextPermutation(int v) { if (v == 0) return 0; else { int t = (v | (v - 1)) + 1; return t | ((((t & -t) / (v & -v)) >> 1) - 1); } } }