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

NextSetBit() 공개 메소드

Returns the index of the first bit that is set to true that occurs on or after the specified starting index.
/// cannot be less than zero. ///
public NextSetBit ( Int32 from ) : Int32
from System.Int32 /// The index to start checking from (inclusive). ///
리턴 System.Int32
		public Int32 NextSetBit(Int32 from) {
			if (from < 0) {
				throw new IndexOutOfRangeException("'from' index cannot be less than zero.");
			}

			this.CheckInvariants();

			Int32 offset = WordIndex(from);
			if (offset >= this._wordsInUse) {
				return -1;
			}

			Int32 result = -1;
			long w = this._bits[offset] & (LONG_MASK << from);
			while (true) {
				if (w != 0) {
					result = (offset * BITS_PER_WORD) + NumberOfTrailingZeros(w);
					break;
				}

				if (++offset == this._wordsInUse) {
					break;
				}
				w = this._bits[offset];
			}

			return result;
		}