public List <ulong> GetFinalAddresses(BitValue bv) { int numPerms = (int)Math.Pow(2, Wildcards.Count); //< Get the 'intermediate' bits (using version 2 mask rules) var interBits = GetIntermediateBits(bv); //< Get the 'base value' from those bits (where all wild cards are 0) ulong baseVal = GetValue(interBits, bv.StartIndex); //< Get the actual numerical values of each wild card when set (1) var wildMap = new Dictionary <byte, ulong>(); for (byte i = 0; i < Wildcards.Count; i++) { byte index = Wildcards.ElementAt(i); wildMap.Add(i, GetValue(bv.StartIndex - index)); } var adds = new List <ulong>() { baseVal }; //< Order the wildcard values first, so we have like (1, 32) for the first case and (1, 2, 8) for the second var wildVals = wildMap.Values.OrderBy(x => x).ToList(); //< Get all the possible combinations of elements in this collection of wild card values (skips the all zero case so returns (2^n) - 1 combos) var combs = Functions.GetPossibleCombinations(wildVals); foreach (var comb in combs) { ulong val = baseVal + comb.Sum(); adds.Add(val); } return(adds); }
public override bool Execute() { var matching = new List <ITaskItem>(); var nonMatching = new List <ITaskItem>(); var options = new Options { AllowWindowsPaths = true, Dot = true, IgnoreCase = true }; var matchers = Wildcards .Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries) .Select(wildcard => new Minimatcher(wildcard.Trim(), options)) .ToList(); foreach (var item in Items) { if (matchers.Any(matcher => matcher.IsMatch(item.ItemSpec)) || matchers.Any(matcher => matcher.IsMatch(item.GetMetadata("Fullpath")))) { matching.Add(item); } else { nonMatching.Add(item); } } MatchingItems = matching.ToArray(); NonMatchingItems = nonMatching.ToArray(); return(true); }
public void Wildcards(string[] wildcardStrs, string[] matches, string[] notMatches) { var wildcards = new Wildcards <Wildcard>(wildcardStrs.Select(wildcardStr => new Wildcard(wildcardStr))); foreach (var match in matches) { Assert.True(wildcards.Contains(match)); } foreach (var notMatch in notMatches) { Assert.False(wildcards.Contains(notMatch)); } }
public BitMask(string[] line) { this.Source = line.Last(); this.Mask = new Dictionary <byte, bool>(); this.Wildcards = new HashSet <byte>(); for (byte i = 0; i < Source.Length; i++) { if (Source[i] == 'X') { Wildcards.Add(i); } else { int val = byte.Parse(Source[i].ToString()); Mask.Add(i, val == 1); } } }
private bool[] GetIntermediateBits(BitValue bv) { var interBits = new bool[bv.Bits.Length]; for (byte i = 0; i < interBits.Length; i++) { if (Wildcards.Contains(i)) { interBits[i] = false; //< Setting false to 'take' the 0 value first } else if (Mask.ContainsKey(i)) { //< If the mask is 1 -> set to 1, else retain original value interBits[i] = Mask[i] ? true : bv.Bits[i]; } else { interBits[i] = bv.Bits[i]; } } return(interBits); }
public List <Word> GetdWordsWildCard(string pattern) { return(GetdWords(W => Wildcards.isMatch(W.PrimarySpelling, pattern, false))); }
protected Word GetRandomUnusedWordByWildCardPattern(int minLen, int maxLen, string wildcard) { return(GetRandomUnusedWord(W => (W.PrimarySpelling.Length >= minLen) && (W.PrimarySpelling.Length <= maxLen) && Wildcards.isMatch(W.PrimarySpelling, wildcard, false))); }
protected Word GetRandomUnusedWordByWildCardPattern(string wildcard) { return(GetRandomUnusedWord(W => Wildcards.isMatch(W.PrimarySpelling, wildcard, false))); }
/// <summary>Returns all files within the directory, matching any <paramref name="Wildcards"/> if given.</summary> /// <param name="Directory">The directory.</param> /// <param name="Wildcards">The wildcards.</param> /// <returns><see cref="IEnumerable{FileInfo}"/></returns> public static IEnumerable <FileInfo> GetFiles(this DirectoryInfo Directory, params string[] Wildcards) => Wildcards.SelectMany(Wildcard => Directory.GetFiles(Wildcard, SearchOption.TopDirectoryOnly));