Пример #1
0
 public WaveletInner(WaveletInner parent, bool building)
     : base(parent)
 {
     if (building) {
         this.B = new FakeBitmap ();
     }
     this.Left = null;
     this.Right = null;
 }
Пример #2
0
 public WaveletLeaf(WaveletInner parent, int symbol, int count)
     : base(parent)
 {
     this.Count = count;
     this.Symbol = symbol;
 }
Пример #3
0
        void Walk(WaveletInner node,
			Func<WaveletInner, object> preorder,
			Func<WaveletInner, object> inorder,
			Func<WaveletInner, object> postorder)
        {
            if (node == null) {
                return;
            }
            if (preorder != null) {
                preorder (node);
            }
            this.Walk (node.Left as WaveletInner, preorder, inorder, postorder);
            if (inorder != null) {
                inorder (node);
            }
            this.Walk (node.Right as WaveletInner, preorder, inorder, postorder);
            if (postorder != null) {
                postorder (node);
            }
        }
Пример #4
0
 WaveletNode LoadNode(BinaryReader Input, WaveletInner parent)
 {
     // Console.WriteLine ("xxxxxxxxx LoadNode");
     var isInner = Input.ReadBoolean ();
     if (isInner) {
         var node = new WaveletInner (parent, false);
         node.B = RankSelectGenericIO.Load (Input);
         var hasLeft = Input.ReadBoolean ();
         if (hasLeft) {
             node.Left = this.LoadNode (Input, node);
         }
         var hasRight = Input.ReadBoolean ();
         if (hasRight) {
             node.Right = this.LoadNode (Input, node);
         }
         return node;
     } else {
         var count = Input.ReadInt32 ();
         var symbol = Input.ReadInt32 ();
         // Console.WriteLine ("--leaf> count: {0}, symbol: {1}", count, symbol);
         var leaf = new WaveletLeaf (parent, symbol, count);
         this.Alphabet[symbol] = leaf;
         return leaf;
     }
 }
Пример #5
0
 void FinishBuild(WaveletInner node)
 {
     if (node == null) {
         return;
     }
     node.B = this.BitmapBuilder(node.B as FakeBitmap);
     this.FinishBuild (node.Left as WaveletInner);
     this.FinishBuild (node.Right as WaveletInner);
 }
Пример #6
0
 public void Load(BinaryReader Input)
 {
     var size = Input.ReadInt32 ();
     this.Alphabet = new WaveletLeaf[size];
     this.Coder = IEncoder32GenericIO.Load (Input);
     // Console.WriteLine ("Input.Position: {0}", Input.BaseStream.Position);
     this.Root = this.LoadNode (Input, null) as WaveletInner;
 }
Пример #7
0
 public void Build(IIEncoder32 coder, int alphabet_size, IList<int> text)
 {
     this.Alphabet = new WaveletLeaf[alphabet_size];
     this.Root = new WaveletInner (null, true);
     this.Coder = coder;
     for (int i = 0; i < text.Count; i++) {
         this.Add (text [i]);
     }
     this.FinishBuild (this.Root);
 }