Esempio n. 1
0
        public List <ReadOnlyProposal> ForSorted()
        {
            List <ReadOnlyProposal> proposals = ProposalBuilder.GetSortedInsurances();
            List <ReadOnlyProposal> result    = new List <ReadOnlyProposal>(64); // cheating

            for (int i = 0; i < proposals.Count; i++)
            {
                ReadOnlyProposal p = proposals[i];
                if (p.InsuranceId == SearchedInsuranceId)
                {
                    if (p.NetPremium > SearchedNetPremium)
                    {
                        result.Add(p);
                    }
                }
                else if (p.InsuranceId > SearchedInsuranceId)
                {
                    break;
                }
            }
            return(result);
        }
Esempio n. 2
0
        // removed, not testing loop speed
        //[Benchmark]
        public List <ReadOnlyProposal> KeyedSorted()
        {
            Dictionary <int, ImmutableArray <ReadOnlyProposal> > proposalsByKey = ProposalBuilder.GetKeyedSortedInsurances();
            List <ReadOnlyProposal> result = new List <ReadOnlyProposal>();

            var proposals = proposalsByKey[SearchedInsuranceId];

            for (int i = 0; i < proposals.Length; i++)
            {
                ReadOnlyProposal p = proposals[i];
                if (p.NetPremium > SearchedNetPremium)
                {
                    result.Add(p);
                }
                else
                {
                    break;
                }
            }

            return(result);
        }
Esempio n. 3
0
        //[Benchmark]
        public List <ReadOnlyProposal> PositionalSorted()
        {
            ImmutableArray <ReadOnlyProposal>[] proposalsByPosition = ProposalBuilder.GetPositionalSortedInsurances();
            List <ReadOnlyProposal>             result = new List <ReadOnlyProposal>();

            var proposals = proposalsByPosition[SearchedInsuranceId];

            for (int i = 0; i < proposals.Length; i++)
            {
                ReadOnlyProposal p = proposals[i];
                if (p.NetPremium > SearchedNetPremium)
                {
                    result.Add(p);
                }
                else
                {
                    break;
                }
            }

            return(result);
        }