예제 #1
0
        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);
        }