virtual public Object Clone() { CharVector cv = new CharVector((char[])array.Clone(), BLOCK_SIZE); cv.n = this.n; return(cv); }
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]); } }
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]); } }
public object Clone() { CharVector cv = new CharVector((char[])_array.Clone(), _blockSize); cv._n = _n; return(cv); }
virtual protected 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(); }
protected void Init() { Root = (char)0; Freenode = (char)1; Length = 0; Lo = new char[BlockSize]; Hi = new char[BlockSize]; Eq = new char[BlockSize]; Sc = new char[BlockSize]; Kv = new CharVector(); }
/** * 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(); }
/// <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(); }
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]); } }
public Object Clone() { CharVector cv = new CharVector((char[])array.Clone(), BLOCK_SIZE); cv.n = this.n; return cv; }