Beispiel #1
0
 public Enumerator(TernaryTree ternaryTree)
 {
     this.outerInstance = ternaryTree;
     cur           = -1;
     ns            = new Stack <Item>();
     ks            = new StringBuilder();
     isInitialized = false;
 }
Beispiel #2
0
        public virtual object Clone()
        {
            TernaryTree t = new TernaryTree();

            t.m_lo       = (char[])this.m_lo.Clone();
            t.m_hi       = (char[])this.m_hi.Clone();
            t.m_eq       = (char[])this.m_eq.Clone();
            t.m_sc       = (char[])this.m_sc.Clone();
            t.m_kv       = (CharVector)this.m_kv.Clone();
            t.m_root     = this.m_root;
            t.m_freenode = this.m_freenode;
            t.m_length   = this.m_length;

            return(t);
        }
Beispiel #3
0
        /// <summary>
        /// Read hyphenation patterns from an <see cref="XmlReader"/>.
        /// </summary>
        /// <param name="source"> <see cref="XmlReader"/> input source for the file </param>
        /// <exception cref="IOException"> In case the parsing fails </exception>
        public virtual void LoadPatterns(XmlReader source)
        {
            PatternParser pp = new PatternParser(this);

            ivalues = new TernaryTree();

            pp.Parse(source);

            // patterns/values should be now in the tree
            // let's optimize a bit
            TrimToSize();
            m_vspace.TrimToSize();
            m_classmap.TrimToSize();

            // get rid of the auxiliary map
            ivalues = null;
        }
Beispiel #4
0
        /// <summary>
        /// Each node stores a character (splitchar) which is part of some key(s). In a
        /// compressed branch (one that only contain a single string key) the trailer
        /// of the key which is not already in nodes is stored externally in the kv
        /// array. As items are inserted, key substrings decrease. Some substrings may
        /// completely disappear when the whole branch is totally decompressed. The
        /// tree is traversed to find the key substrings actually used. In addition,
        /// duplicate substrings are removed using a map (implemented with a
        /// TernaryTree!).
        ///
        /// </summary>
        public virtual void TrimToSize()
        {
            // first balance the tree for best performance
            Balance();

            // redimension the node arrays
            RedimNodeArrays(m_freenode);

            // ok, compact kv array
            CharVector kx = new CharVector();

            kx.Alloc(1);
            TernaryTree map = new TernaryTree();

            Compact(kx, map, m_root);
            m_kv = kx;
            m_kv.TrimToSize();
        }