Exemple #1
0
        /// <summary>
        /// Converts the ISequenceItem passed in as a parameter from one collection
        /// of such items to another. This is useful in going from encoded items to
        /// alphabet items for instance.
        /// </summary>
        public ISequenceItem Convert(ISequenceItem item)
        {
            if (direction == EncodingMapDirection.AlphabetToEncoding)
            {
                if (!alphabet.Contains(item))
                {
                    throw new ArgumentException("The alphabet does not contain the item being mapped");
                }
                return(map[item]);
            }
            else if (direction == EncodingMapDirection.EncodingToAlphabet)
            {
                if (!encoding.Contains(item))
                {
                    throw new ArgumentException("The encoding does not contain the item being mapped");
                }
                return(map[item]);
            }

            throw new Exception("Internal Error: Unrecognized encoding map direction");
        }