コード例 #1
0
ファイル: NodeSorter.cs プロジェクト: saltisgood/word-solver
 /// <summary>
 /// Retrieve the cached instance of the NodeSorter
 /// </summary>
 /// <returns></returns>
 public static NodeSorter GetInstance()
 {
     if (_instance == null)
     {
         _instance = new NodeSorter();
     }
     return(_instance);
 }
コード例 #2
0
ファイル: DictTree.cs プロジェクト: saltisgood/word-solver
        /// <summary>
        /// Write the whole dictionary to a stream with optional alphabetical sorting
        /// </summary>
        /// <param name="sw">The stream to write to</param>
        /// <param name="sortFirst">Whether the words should be sorted</param>
        public void WriteToStream(StreamWriter sw, bool sortFirst)
        {
            if (sortFirst)
            {
                Children.Sort(NodeSorter.GetInstance());
            }

            foreach (DictNode n in Children)
            {
                n.WriteToStream(sw, true);
            }
        }
コード例 #3
0
        /// <summary>
        /// Serialise the node as part of a full tree write
        /// </summary>
        /// <param name="sw">The stream to write to</param>
        /// <param name="sortFirst">True to alphabetically sort the child nodes first</param>
        public void WriteToStream(StreamWriter sw, bool sortFirst)
        {
            if (sortFirst)
            {
                Children.Sort(NodeSorter.GetInstance());
            }

            if (_isWord)
            {
                sw.WriteLine(this.ToString());
            }

            foreach (DictNode n in Children)
            {
                n.WriteToStream(sw, sortFirst);
            }
        }