本文整理汇总了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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例6: Result
/// <summary>Constructor</summary>
public Result(bool best, BitArray bestHandBits, PokerHand bestHand, PokerHand selectedHand)
{
_best = best;
_bestHandBits = bestHandBits;
_bestHand = bestHand;
_selectedHand = selectedHand;
}
示例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();
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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(")");
}
示例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);
}
示例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;
}
示例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;
}