public void Prune(int size)
        {
            if (mNondominatedSortRequired)
            {
                FastNondominatedSort(this);
            }

            Sort(delegate(S s1, S s2)
            {
                return(CompareUtil.RankCompare(s1, s2));
            });


            int            maxRank = mIndividuals[size - 1].Rank;
            Population <S> front   = new Population <S>();

            for (int i = Count - 1; i >= 0; i--)
            {
                S   solution = mIndividuals[i];
                int rank     = solution.Rank;

                if (rank >= maxRank)
                {
                    mIndividuals.RemoveAt(i);

                    if (rank == maxRank)
                    {
                        front.Add(solution);
                    }
                }
            }

            while (Count + front.Count > size)
            {
                SortUtil.UpdateCrowdingDistance(front);
                front.Truncate(front.Count - 1, delegate(S s1, S s2)
                {
                    return(CompareUtil.CrowdingDistanceCompare(s1, s2));
                });
            }

            foreach (S s in front.Solutions)
            {
                Add(s);
            }
        }
 public void FastNondominatedSort(Population <S> population)
 {
     mNondominatedSortRequired = false;
     SortUtil.FastNondominatedSort(population);
 }