예제 #1
0
        public TextProcessor InsertOrs()
        {
            CircularDoublyLinkedList <string> newTextList = new CircularDoublyLinkedList <string>();

            Text.TextList.ForEach(node => {
                newTextList.Append(node.data);
                newTextList.Append("or");
            });

            Text.TextList = newTextList;

            return(this);
        }
예제 #2
0
        public CircularDoublyLinkedList <T> Filter(FilterLambda predicate)
        {
            CircularDoublyLinkedList <T> newList = new CircularDoublyLinkedList <T>();

            ForEach(node =>
            {
                if (predicate(node))
                {
                    newList.Append(node.data);
                }
            });

            return(newList);
        }
예제 #3
0
        public void ReadText(string path)
        {
            TextList = new CircularDoublyLinkedList <string>();

            try {
                using (StreamReader sr = new StreamReader(path))
                {
                    String   line  = sr.ReadToEnd();
                    String[] words = SplitTextBySeparator(line);

                    foreach (string word in words)
                    {
                        TextList.Append(word);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("The file could not be read:");
                Console.WriteLine(e.Message);
            }
        }
예제 #4
0
        public TextProcessor ProcessWordsWithMoreThanNCharacters(int n)
        {
            CircularDoublyLinkedList <string> newTextList = new CircularDoublyLinkedList <string>();

            Text.TextList.ForEach(node => {
                string value = node.data;
                int length   = value.Length;

                if (length > n)
                {
                    newTextList.Append(value.Substring(0, length - n) + value[length - 1]);
                }
                else
                {
                    newTextList.Append(value);
                }
            });

            Text.TextList = newTextList;

            return(this);
        }