CyrusBuilt.MonoPi.BitSet.ValueOf C# (CSharp) 메소드

ValueOf() 공개 정적인 메소드

Returns a new bit set containing all the bits in the specified byte array.
public static ValueOf ( Byte bytes ) : BitSet
bytes Byte /// A byte array containing a little-endian representation of a /// sequence of bits to be used as the intial set of the new bit set. ///
리턴 BitSet
		public static BitSet ValueOf(Byte[] bytes) {
			Int32 n = 0;
			for (n = bytes.Length; n > 0 && (Int32)bytes.GetValue(n - 1) == 0; n--) {
				;
			}

			long[] words = new long[(n + 7) / 8];
			using (MemoryStream ms = new MemoryStream(bytes)) {
				ms.Capacity = n;
				using (BinaryReader reader = new BinaryReader(ms)) {
					Int32 i = 0;
					while (ms.Position >= 8) {
						words[i++] = reader.ReadInt64();
					}
						
					for (Int32 remaining = (Int32)ms.Position, j = 0; j < remaining; j++) {
						words[i] |= (reader.Read() & 0xffL) << (8 * j);
					}
				}
			}
			return new BitSet(words);
		}

Same methods

BitSet::ValueOf ( long words ) : BitSet