将一个Int与另一个Ints列表进行比较,以查看Int是否在Ints列表中,以避免出现很多if语句

时间:2018-10-10 13:40:11

标签: ios swift binary

我有一个二进制数。该二进制文件具有256种可能性。我只需要检查其中47种可能性。

很难解释且不相关,但是/** * Returns the array element at the given [index]. * This method can be called using the index operator. */ public operator fun get(index: Int): Long point[]的数组,我可以通过检查SKTileMapNode中的周围图块来获得。

Int

binary = 1,binary = 2,binary = 3,依此类推。

我只需要256种可能性中的47种。有没有一种简便的方法可以针对这47个检查我的let number = 1 * point[0] + 2 * point[1] + 4 * point[2] + 8 * point[3] + 16 * point[4] + 32 * point[5] + 64 * point[6] + 128 * point[7] //=======o // 1-10 { 2 = 1, 8 = 2, 10 = 3, 11 = 4, 16 = 5, 18 = 6, 22 = 7, 24 = 8, 26 = 9, 27 = 10, } // 11-19 { 30 = 11, 31 = 12, 64 = 13, 66 = 14, 72 = 15, 74 = 16, 75 = 17, 80 = 18, 82 = 19,} // 20-28 { 86 = 20, 88 = 21, 90 = 22, 91 = 23, 94 = 24, 95 = 25, 104 = 26, 106 = 27, 107 = 28, } // 29-37 { 120 = 29, 122 = 30, 123 = 31, 126 = 32, 127 = 33, 208 = 34, 210 = 35, 214 = 36, 216 = 37, } // 38-47 { 218 = 38, 219 = 39, 222 = 40, 223 = 41, 248 = 42, 250 = 43, 251 = 44, 254 = 45, 255 = 46, 0 = 47 } //=======o 而不必编写47个if语句?

0 个答案:

没有答案