1 package org.columba.core.base; 17 18 public class BooleanCompressor { 19 public static int compress(Boolean [] input) { 20 int result = 0; 21 22 for (int i = 0; i < input.length; i++) { 23 if (input[i].booleanValue()) { 24 result |= (1 << i); 25 } 26 } 27 28 return result; 29 } 30 31 public static Boolean decompress(int input, int index) { 32 if (((input >> index) & 1) == 1) { 33 return Boolean.TRUE; 34 } 35 return Boolean.FALSE; 36 } 37 } 38 | Popular Tags |