This class implements a simple char vector with access to the underlying array. This class has been taken from the Apache FOP project (http://xmlgraphics.apache.org/fop/). They have been slightly modified.
Inheritance: ICloneable
Exemplo n.º 1
0
        public override CharVector clone()
        {
            CharVector cv = new CharVector(array.Clone(), blockSize);

            cv.n = this.n;
            return(cv);
        }
Exemplo n.º 2
0
        private void compact(CharVector kx, TernaryTree map, char p)
        {
            int k;

            if (p == 0)
            {
                return;
            }
            if (sc[p] == 0xFFFF)
            {
                k = map.find(kv.Array, lo[p]);
                if (k < 0)
                {
                    k = kx.alloc(strlen(kv.Array, lo[p]) + 1);
                    strcpy(kx.Array, k, kv.Array, lo[p]);
                    map.insert(kx.Array, 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]);
            }
        }
Exemplo n.º 3
0
 protected internal virtual void init()
 {
     root     = (char)0;
     freenode = (char)1;
     length   = 0;
     lo       = new char[BLOCK_SIZE];
     hi       = new char[BLOCK_SIZE];
     eq       = new char[BLOCK_SIZE];
     sc       = new char[BLOCK_SIZE];
     kv       = new CharVector();
 }
Exemplo n.º 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();
        }
Exemplo n.º 5
0
	  public override CharVector clone()
	  {
		CharVector cv = new CharVector(array.Clone(), blockSize);
		cv.n = this.n;
		return cv;
	  }