Example #1
0
        //todo test
        public CompositionAlternatives2(CompositionAlternatives2 alternatives1, CompositionAlternatives2 alternatives2)
        {
            _blobCompositions = new List <BlobComposition>();
            _blobCompositions.AddRange(alternatives1.BlobCompositions);
            _blobCompositions.AddRange(alternatives2.BlobCompositions);

            CharPool = alternatives1.CharPool;
        }
Example #2
0
        //todo test
        private void ValidateInputMultiple(string anagramCharPool, CompositionAlternatives2 alternatives)
        {
            if (alternatives == null)
            {
                throw new ArgumentException("Can not be null", nameof(alternatives));
            }

            if (string.IsNullOrEmpty(anagramCharPool))
            {
                throw new ArgumentException("Can not be null or empty", nameof(anagramCharPool));
            }
        }
Example #3
0
        //todo test
        public void AddMultiple(string anagramCharPool, CompositionAlternatives2 alternatives)
        {
            ValidateInputMultiple(anagramCharPool, alternatives);

            if (_dict.ContainsKey(anagramCharPool))
            {
                var els = _dict[anagramCharPool];
                _dict[anagramCharPool] = new CompositionAlternatives2(alternatives, els);
            }
            else
            {
                _dict.Add(anagramCharPool, alternatives);
            }
        }
Example #4
0
        //todo test
        public static CompositionAlternatives2 GetCombined(CompositionAlternatives2 prefixes, Blob suffix)
        {
            if (prefixes == null)
            {
                throw new ArgumentException("Prefix composition alternatives can not be null", nameof(prefixes));
            }

            if (suffix == null)
            {
                throw new ArgumentException("Suffix blob can not be null", nameof(suffix));
            }

            if (prefixes.IsDeadend)
            {
                return(DeadEnd);
            }

            var blobCompositions = prefixes.BlobCompositions.Select(x => new BlobComposition(x, suffix)).ToList();
            var charPool         = string.Concat(prefixes.CharPool, suffix.CharPool).Alphabetize();

            return(new CompositionAlternatives2(charPool, blobCompositions));
        }