Esempio n. 1
0
        private static void Redistribute(List <int[]> blocks, HighestData data)
        {
            int distribute = (int)Math.Ceiling(data.MaxItems / (double)(blocks.Count));
            int counter    = blocks[data.StartIndex].Length;
            int index      = data.StartIndex;

            blocks[data.StartIndex] = new int[0];

            while (counter != 0)
            {
                index++;
                if (index == blocks.Count)                   //after last item in list, wrap around
                {
                    index = 0;
                }

                if (counter < distribute)
                {
                    blocks[index] = new int[counter];
                    counter       = 0;
                }
                else
                {
                    int size = blocks[index].Length;
                    blocks[index] = new int[size + distribute];
                    counter      -= distribute;
                }
            }
        }
Esempio n. 2
0
        private static HighestData GetHighestData(List <int[]> blocks)
        {
            var data = new HighestData();

            for (int i = 0; i < blocks.Count; i++)
            {
                var block = blocks[i];
                if (block.Length > data.MaxItems)
                {
                    data.MaxItems   = block.Length;
                    data.StartIndex = i;
                }
            }
            return(data);
        }