Exemplo n.º 1
0
 public static int GetNumberOfLeadingZeros(uint n)
 {
     n = n | n >> 1;
     n = n | n >> 2;
     n = n | n >> 4;
     n = n | n >> 8;
     n = n | n >> 16;
     return(PopulationCount.GetPopulationCount(~n));
 }
Exemplo n.º 2
0
 public static int GetPopulationCount(ulong n)
 {
     n = n | n >> 1;
     n = n | n >> 2;
     n = n | n >> 4;
     n = n | n >> 8;
     n = n | n >> 16;
     n = n | n >> 32;
     return(PopulationCount.GetPopulationCount(~n));
 }
Exemplo n.º 3
0
        public AgeFileMap()
        {
            Map(m => m.Code).Convert(row =>
            {
                return(row.Row.GetField <string>(0));
            });

            Map(m => m.Name).Convert(row =>
            {
                return(row.Row.GetField <string>(1));
            });

            Map(m => m.Type).Convert(row =>
            {
                AreaType type = EnumParser <AreaType> .GetValueFromName(row.Row.GetField <string>(2));
                return(type);
            });


            Map(m => m.Population).Convert(row => {
                var list = new List <PopulationCount>();
                for (int i = 0; i <= 90; i++)
                {
                    var count    = new PopulationCount();
                    count.MinAge = i;

                    var pop          = row.Row.GetField <string>(i + 4);
                    count.Population = int.Parse(pop, NumberStyles.AllowThousands);

                    if (i != 90)
                    {
                        count.MaxAge = i;
                    }
                    else
                    {
                        count.MaxAge = int.MaxValue;
                    }
                    list.Add(count);
                }

                return(list);
            });
        }
Exemplo n.º 4
0
 /// <summary>
 /// 立ってるビットの数を数える
 /// </summary>
 /// <param name="n">立ってるビットの数を数える</param>
 /// <returns></returns>
 public static long GetPopulationCount(long n)
 {
     return(PopulationCount.GetPopulationCount((ulong)n));
 }
Exemplo n.º 5
0
 /// <summary>
 /// 立ってるビットの数を数える
 /// </summary>
 /// <param name="n">立ってるビットの数を数える</param>
 /// <returns></returns>
 public static long GetPopulationCount(int n)
 {
     return(PopulationCount.GetPopulationCount((uint)n));
 }