Inheritance: ICloneable
コード例 #1
0
 public HyphenationTree()
 {
     stoplist = new Dictionary<string,List<object>>(23);    // usually a small table
     classmap = new TernaryTree();
     vspace = new ByteVector();
     vspace.Alloc(1);    // this reserves index 0, which we don't use
 }
コード例 #2
0
 public Iterator(TernaryTree parent)
 {
     this.parent = parent;
     cur         = -1;
     ns          = new Stack();
     ks          = new StringBuilder();
     Rewind();
 }
コード例 #3
0
 public Iterator(TernaryTree parent)
 {
     _parent = parent;
     _cur    = -1;
     _ns     = new Stack();
     _ks     = new StringBuilder();
     Rewind();
 }
コード例 #4
0
ファイル: TernaryTree.cs プロジェクト: mbarylsk/pdf-tools
        virtual public Object Clone()
        {
            TernaryTree t = new TernaryTree();

            t.lo       = (char[])this.lo.Clone();
            t.hi       = (char[])this.hi.Clone();
            t.eq       = (char[])this.eq.Clone();
            t.sc       = (char[])this.sc.Clone();
            t.kv       = (CharVector)this.kv.Clone();
            t.root     = this.root;
            t.freenode = this.freenode;
            t.length   = this.length;

            return(t);
        }
コード例 #5
0
        public object Clone()
        {
            TernaryTree t = new TernaryTree();

            t.Lo       = (char[])Lo.Clone();
            t.Hi       = (char[])Hi.Clone();
            t.Eq       = (char[])Eq.Clone();
            t.Sc       = (char[])Sc.Clone();
            t.Kv       = (CharVector)Kv.Clone();
            t.Root     = Root;
            t.Freenode = Freenode;
            t.Length   = Length;

            return(t);
        }
コード例 #6
0
        public void LoadSimplePatterns(Stream stream) {
            SimplePatternParser pp = new SimplePatternParser();
            ivalues = new TernaryTree();

            pp.Parse(stream, this);

            // 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;
        }
コード例 #7
0
        public object Clone()
        {
            var t = new TernaryTree
            {
                Lo       = (char[])Lo.Clone(),
                Hi       = (char[])Hi.Clone(),
                Eq       = (char[])Eq.Clone(),
                Sc       = (char[])Sc.Clone(),
                Kv       = (CharVector)Kv.Clone(),
                Root     = Root,
                Freenode = Freenode,
                Length   = Length
            };

            return(t);
        }
コード例 #8
0
        /**
         * Read hyphenation patterns from an internal format file.
         */
        public void loadInternalPatterns(Stream istr)
        {
            PatternInternalParser pp = new PatternInternalParser(this);

            ivalues = new TernaryTree();

            pp.parse(istr);

            // 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;
        }
コード例 #9
0
ファイル: TernaryTree.cs プロジェクト: mbarylsk/pdf-tools
        /**
         * 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!).
         *
         */
        virtual public 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();
        }
コード例 #10
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 void TrimToSize()
        {
            // first balance the tree for best performance
            Balance();

            // redimension the node arrays
            redimNodeArrays(Freenode);

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

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

            compact(kx, map, Root);
            Kv = kx;
            Kv.TrimToSize();
        }
コード例 #11
0
 public Iterator(TernaryTree parent) {
     this.parent = parent;
     cur = -1;
     ns = new Stack();
     ks = new StringBuilder();
     Rewind();
 }
コード例 #12
0
 private void Compact(CharVector kx, TernaryTree map, char p) {
     int k;
     if (p == 0)
         return;
     if (sc[p] == 0xFFFF) {
         k = map.Find(kv.Arr, lo[p]);
         if (k < 0) {
             k = kx.Alloc(Strlen(kv.Arr, lo[p]) + 1);
             Strcpy(kx.Arr, k, kv.Arr, lo[p]);
             map.Insert(kx.Arr, k, (char)k);
         }
         lo[p] = (char)k;
     } else {
         Compact(kx, map, lo[p]);
         if (sc[p] != 0)
             Compact(kx, map, eq[p]);
         Compact(kx, map, hi[p]);
     }
 }
コード例 #13
0
        /**
         * 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!).
         *
         */
        virtual public 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();
        }
コード例 #14
0
        virtual public Object Clone() {
            TernaryTree t = new TernaryTree();
            t.lo = (char[])this.lo.Clone();
            t.hi = (char[])this.hi.Clone();
            t.eq = (char[])this.eq.Clone();
            t.sc = (char[])this.sc.Clone();
            t.kv = (CharVector)this.kv.Clone();
            t.root = this.root;
            t.freenode = this.freenode;
            t.length = this.length;

            return t;
        }
コード例 #15
0
        virtual public void LoadSimplePatterns(Stream stream) {
            SimplePatternParser pp = new SimplePatternParser();
            ivalues = new TernaryTree();

            pp.Parse(stream, this);

            // 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;
        }
コード例 #16
0
 public HyphenationTree() {
     stoplist = new Hashtable(23);    // usually a small table
     classmap = new TernaryTree();
     vspace = new ByteVector();
     vspace.Alloc(1);    // this reserves index 0, which we don't use
 }