当前位置: 首页>>代码示例>>C#>>正文


C# Collections.BitArray类代码示例

本文整理汇总了C#中System.Collections.BitArray的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.BitArray类的具体用法?C# System.Collections.BitArray怎么用?C# System.Collections.BitArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


System.Collections.BitArray类属于命名空间,在下文中一共展示了System.Collections.BitArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Bloom

        public Bloom(int elements, double falsePositiveRate)
        {
            var size = (int)(-elements * Math.Log(falsePositiveRate) / Math.Pow(Math.Log(2), 2)) / 8;
            HashFunctions = (int)(size * 8 / elements * Math.Log(2));

            Bits = new System.Collections.BitArray(size * 8);
        }
开发者ID:Frassle,项目名称:Ibasa,代码行数:7,代码来源:Bloom.cs

示例2: GetDocIdSet

			public override DocIdSet GetDocIdSet(IndexReader reader)
			{
				System.Collections.BitArray bitset = new System.Collections.BitArray((5 % 64 == 0?5 / 64:5 / 64 + 1) * 64);
				bitset.Set(1, true);
				bitset.Set(3, true);
				return new DocIdBitSet(bitset);
			}
开发者ID:Rationalle,项目名称:ravendb,代码行数:7,代码来源:TestFilteredQuery.cs

示例3: WD_HW_StatusDesc

 public WD_HW_StatusDesc(string devName,byte[] status, byte[] diff)
 {
     ArrayhwStatus = new System.Collections.BitArray(status);
     this.diff = diff;
     this.devName = devName;
     m_status = status;
 }
开发者ID:ufjl0683,项目名称:sshmc,代码行数:7,代码来源:WD_HW_StatusDesc.cs

示例4: Bits

			public override System.Collections.BitArray Bits(IndexReader reader)
			{
				System.Collections.BitArray bitset = new System.Collections.BitArray((5 % 64 == 0?5 / 64:5 / 64 + 1) * 64);
				bitset.Set(1, true);
				bitset.Set(3, true);
				return bitset;
			}
开发者ID:runefs,项目名称:Marvin,代码行数:7,代码来源:TestFilteredQuery.cs

示例5: Bits

		public override System.Collections.BitArray Bits(IndexReader reader)
		{
			System.Collections.BitArray bits = new System.Collections.BitArray((reader.MaxDoc() % 64 == 0 ? reader.MaxDoc() / 64 : reader.MaxDoc() / 64 + 1) * 64);
			
			new IndexSearcher(reader).Search(query, new AnonymousClassHitCollector(bits, this));
			return bits;
		}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:7,代码来源:QueryWrapperFilter.cs

示例6: Result

 /// <summary>Constructor</summary>
 public Result(bool best, BitArray bestHandBits, PokerHand bestHand, PokerHand selectedHand)
 {
     _best = best;
     _bestHandBits = bestHandBits;
     _bestHand = bestHand;
     _selectedHand = selectedHand;
 }
开发者ID:AlexMaskovyak,项目名称:rit-4005-714-maskovyak-pecoraro,代码行数:8,代码来源:Result.cs

示例7: PartialFile

        public PartialFile(string path, int targetSize)
        {
            this.path = path;

            if (File.Exists(path)) {
                isCompleted = true;

                if (targetSize != -1 && new FileInfo(path).Length != targetSize) {
                    throw new ApplicationException("Attempting to initialize the size with an invalid size");
                }
                stream = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read);

            } else if (File.Exists(PartialFileName)) {

                stream = File.Open(PartialFileName, FileMode.Open, FileAccess.ReadWrite, FileShare.None);
                ReadBitmapInfo();

            } else {
                if (targetSize == -1) targetSize = DEFAULT_SIZE;
                var chunks = targetSize / CHUNK_SIZE;

                if (targetSize % CHUNK_SIZE > 0) chunks++;

                completedChunks = new System.Collections.BitArray(chunks, false);

                stream = File.Open(PartialFileName, FileMode.Create, FileAccess.ReadWrite, FileShare.None);
                WriteBitmapInfo();
            }
        }
开发者ID:xantilas,项目名称:ghalager-videobrowser-20120129,代码行数:29,代码来源:PartialFile.cs

示例8: RGS_HW_StatusDesc

 public RGS_HW_StatusDesc(string devName,byte[] hw_status, byte[] diff)
 {
     ArrayhwStatus = new System.Collections.BitArray(hw_status);
     this.diff = diff;
     this.devName = devName;
     this.m_status = hw_status;
 }
开发者ID:ufjl0683,项目名称:Center,代码行数:7,代码来源:RGS_HW_StausDesc.cs

示例9: Bits

        public override System.Collections.BitArray Bits(IndexReader reader)
        {
            if (cache == null)
            {
                cache = new System.Collections.Hashtable();
            }

            lock (cache.SyncRoot)
            {
                // check cache
                System.Collections.BitArray cached = (System.Collections.BitArray) cache[reader];
                if (cached != null)
                {
                    return cached;
                }
            }

            System.Collections.BitArray bits = new System.Collections.BitArray((reader.MaxDoc() % 64 == 0?reader.MaxDoc() / 64:reader.MaxDoc() / 64 + 1) * 64);

            new IndexSearcher(reader).Search(query, new AnonymousClassHitCollector(bits, this));

            lock (cache.SyncRoot)
            {
                // update cache
                cache[reader] = bits;
            }

            return bits;
        }
开发者ID:karino2,项目名称:wikipediaconv,代码行数:29,代码来源:QueryFilter.cs

示例10: FindPrimes

        public static IList<int> FindPrimes(int max)
        {
            //Initialize list to capacity using Legendre's constant to minimize copying lists as bounds are exceeded
              var vals = new List<int>((int)(max / (Math.Log(max) - 1.08366)));

              var maxSquareRoot = Math.Sqrt(max);

              //Use a BitArray for light-weight collection of numbers already elminated as not prime.
              var eliminated = new System.Collections.BitArray(max + 1);

              //2 is the only even prime, add it here and skip evaluating all even numbers below
              vals.Add(2);

              for (int i = 3; i <= max; i += 2)
              {
            if (!eliminated[i])
            {
              //We only need to evaluate up to sqrt (any non-primes beyond will already be eliminated as a multiple)
              if (i < maxSquareRoot)
              {
            //Eliminate all multiples i (after i squared, lower multiple are already eliminated)
            for (int j = i * i; j <= max; j += 2 * i)
              eliminated[j] = true;
              }

              //Add number to primes if it hasn't been eliminated
              vals.Add(i);
            }
              }
              return vals;
        }
开发者ID:Alric,项目名称:ProjectEuler,代码行数:31,代码来源:PrimeHelper.cs

示例11: Rasterize

        public static bool[,] Rasterize(Point[] points, int width, int height)
        {
            Contract.Requires(points != null);
            Contract.Requires(width > 0);
            Contract.Requires(height > 0);
            Contract.Requires(width % 8 == 0);
            Contract.Ensures(Contract.Result<bool[,]>() != null);
            Contract.Ensures(Contract.Result<bool[,]>().GetLength(0) == width);
            Contract.Ensures(Contract.Result<bool[,]>().GetLength(1) == height);

            var canvas = new Canvas { Background = Brushes.White, Width = width, Height = height };
            var polygon = new Polygon { Stroke = Brushes.Black, Fill = Brushes.Black, StrokeThickness = 1, Points = new PointCollection(points) };
            canvas.Children.Add(polygon);
            RenderOptions.SetEdgeMode(canvas, EdgeMode.Aliased);

            canvas.Measure(new Size(width, height));
            canvas.Arrange(new Rect(0, 0, canvas.DesiredSize.Width, canvas.DesiredSize.Height));

            var rtb = new RenderTargetBitmap(width, height, 96, 96, PixelFormats.Default);
            rtb.Render(canvas);

            var fmb = new FormatConvertedBitmap(rtb, PixelFormats.BlackWhite, null, 0);
            var pixels = new byte[width * height / 8];
            fmb.CopyPixels(pixels, width / 8, 0);

            System.Collections.BitArray ba = new System.Collections.BitArray(pixels);

            var result = new bool[width, height];
            for (int i = 0, y = 0; y < height; ++y)
                for (int x = 0; x < width; ++x, ++i)
                    result[x, y] = !ba[i];

            return result;
        }
开发者ID:alexshtf,项目名称:Various-utility-projects,代码行数:34,代码来源:PolygonRasterizer.cs

示例12: BuildPatternBodyImpl

        protected override void BuildPatternBodyImpl(StringBuilder pattern, ICollection<string> requiredVariables, ICollection<string> arrayVariables, ICollection<string> mapVariables)
        {
            if (pattern == null)
                throw new ArgumentNullException("pattern");
            if (arrayVariables == null)
                throw new ArgumentNullException("arrayVariables");
            if (mapVariables == null)
                throw new ArgumentNullException("mapVariables");

            BitArray requiredPatterns = new BitArray(Variables.Count);
            List<string> variablePatterns = new List<string>();
            for (int i = 0; i < Variables.Count; i++)
            {
                VariableReference variable = Variables[i];
                if (requiredVariables.Contains(variable.Name))
                    requiredPatterns.Set(i, true);

                bool allowReservedSet = false;
                variablePatterns.Add(BuildVariablePattern(variable, allowReservedSet, null, requiredVariables, arrayVariables, mapVariables));
            }

            pattern.Append("(?:");
            AppendZeroOrMoreToEnd(pattern, requiredPatterns, variablePatterns, 0);
            pattern.Append(")");
        }
开发者ID:gitter-badger,项目名称:dotnet-uritemplate,代码行数:25,代码来源:UriTemplatePartLabelExpansion.cs

示例13: UriUtility

        static UriUtility()
        {
#if PORTABLE
            if (!Enum.TryParse("Compiled", out DefaultRegexOptions))
                DefaultRegexOptions = RegexOptions.None;
#else
            DefaultRegexOptions = RegexOptions.Compiled;
#endif

            _unreservedCharacters = new BitArray(256);
            for (char i = 'a'; i <= 'z'; i++)
                _unreservedCharacters.Set(i, true);
            for (char i = 'A'; i <= 'Z'; i++)
                _unreservedCharacters.Set(i, true);
            for (char i = '0'; i <= '9'; i++)
                _unreservedCharacters.Set(i, true);
            _unreservedCharacters.Set('-', true);
            _unreservedCharacters.Set('.', true);
            _unreservedCharacters.Set('_', true);
            _unreservedCharacters.Set('~', true);

            _generalDelimiters = new BitArray(256);
            _generalDelimiters.Set(':', true);
            _generalDelimiters.Set('/', true);
            _generalDelimiters.Set('?', true);
            _generalDelimiters.Set('#', true);
            _generalDelimiters.Set('[', true);
            _generalDelimiters.Set(']', true);
            _generalDelimiters.Set('@', true);

            _subDelimiters = new BitArray(256);
            _subDelimiters.Set('!', true);
            _subDelimiters.Set('$', true);
            _subDelimiters.Set('&', true);
            _subDelimiters.Set('(', true);
            _subDelimiters.Set(')', true);
            _subDelimiters.Set('*', true);
            _subDelimiters.Set('+', true);
            _subDelimiters.Set(',', true);
            _subDelimiters.Set(';', true);
            _subDelimiters.Set('=', true);
            _subDelimiters.Set('\'', true);

            _reservedCharacters = new BitArray(256).Or(_generalDelimiters).Or(_subDelimiters);

            _allowedHostCharacters = new BitArray(256).Or(_unreservedCharacters).Or(_subDelimiters);

            _allowedPathCharacters = new BitArray(256).Or(_unreservedCharacters).Or(_subDelimiters);
            _allowedPathCharacters.Set(':', true);
            _allowedPathCharacters.Set('@', true);

            _allowedQueryCharacters = new BitArray(256).Or(_allowedPathCharacters);
            _allowedQueryCharacters.Set('/', true);
            _allowedQueryCharacters.Set('?', true);

            _allowedFragmentCharacters = new BitArray(256).Or(_allowedPathCharacters);
            _allowedFragmentCharacters.Set('/', true);
            _allowedFragmentCharacters.Set('?', true);
        }
开发者ID:crowdy,项目名称:OpenStack-ConoHa,代码行数:59,代码来源:UriUtility.cs

示例14: ThreadPlaySound

   public ThreadPlaySound(int recordid, int cnt, System.Collections.BitArray Status, TouchPanelManager touch_panel_mgr,Controller controller)
 {
     this.recordid = recordid;
     this.cnt = cnt;
     this.Status = Status;
     this.touch_panel_mgr = touch_panel_mgr;
     this.controller = controller;
 }
开发者ID:ufjl0683,项目名称:wirelessBrocast,代码行数:8,代码来源:ThreadPlaySound.cs

示例15: ToOpenTK

		public static BitArray ToOpenTK(this Keys buttons)
		{
			BitArray result = new BitArray((int)Key.LastKey + 1, false);
			int k;
			if (mapToOpenTK.TryGetValue((int)(buttons & ~Keys.Modifiers), out k))
				result[k] = true;
			return result;
		}
开发者ID:Andrea,项目名称:duality-withsvn-history,代码行数:8,代码来源:ExtMethodsKeys.cs


注:本文中的System.Collections.BitArray类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。