Ejemplo n.º 1
0
 public Iterator(TernaryTree parent)
 {
     this.parent = parent;
     cur         = -1;
     ns          = new Stack();
     ks          = new StringBuilder();
     Rewind();
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
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;
        }
Ejemplo n.º 4
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!).
         *
         */
        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();
        }