Пример #1
0
 public Iterator(TernaryTree outerInstance)
 {
     this.outerInstance = outerInstance;
     cur = -1;
     ns  = new Stack <>();
     ks  = new StringBuilder();
     rewind();
 }
Пример #2
0
        public override TernaryTree clone()
        {
            TernaryTree t = new TernaryTree();

            t.lo       = this.lo.Clone();
            t.hi       = this.hi.Clone();
            t.eq       = this.eq.Clone();
            t.sc       = this.sc.Clone();
            t.kv       = this.kv.clone();
            t.root     = this.root;
            t.freenode = this.freenode;
            t.length   = this.length;

            return(t);
        }
Пример #3
0
        /// <summary>
        /// Read hyphenation patterns from an XML file.
        /// </summary>
        /// <param name="source"> the InputSource for the file </param>
        /// <exception cref="IOException"> In case the parsing fails </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void loadPatterns(org.xml.sax.InputSource source) throws java.io.IOException
        public virtual void loadPatterns(InputSource 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();
            vspace.trimToSize();
            classmap.trimToSize();

            // get rid of the auxiliary map
            ivalues = null;
        }
Пример #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(freenode);

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

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

            compact(kx, map, root);
            kv = kx;
            kv.trimToSize();
        }