Beispiel #1
0
        private void BuildTree( Node currentNode, DecompressorState state, int level )
        {
            bool flag = state.Flag;
            state.NextNode();

            currentNode.Level = level;
            currentNode.Flag = flag;
            if ( flag && level > 1 ) {
                currentNode.CreateBranches( );

                BuildTree( currentNode.BottomRightChild, state, level-1 );
                BuildTree( currentNode.BottomLeftChild, state, level-1 );
                BuildTree( currentNode.TopRightChild, state, level-1 );
                BuildTree( currentNode.TopLeftChild, state, level-1 );
            }
            else {
                if ( flag ) {
                    currentNode.CreateLeaves();
                    state.AddLeaves( );
                }
                else {
                    currentNode.BecomeLeaf();
                    state.AddLeaf( );
                }
            }
        }