Beispiel #1
0
        protected HuffmanNode(HuffmanNode aParent, int aValue)
        {
            parent = aParent;

            if (parent != null)
            {
                depth = parent.GetDepth() + 1;
            }

            value = aValue;

            isFull     = true;
            isSetValue = true;
        }
Beispiel #2
0
        public bool SetNewValue(int aDepth, int aValue)
        {
            if (GetFullFlag() == true)
            {
                return(false);
            }

            if (aDepth == 1)
            {
                if (o0 == null)
                {
                    o0 = new HuffmanNode(this, aValue);

                    return(true);
                }

                if (o1 == null)
                {
                    o1 = new HuffmanNode(this, aValue);

                    return(true);
                }
            }
            else
            {
                if (o0 == null)
                {
                    o0 = new HuffmanNode(this);
                }

                if (o0.SetNewValue(aDepth - 1, aValue) == true)
                {
                    return(true);
                }

                if (o1 == null)
                {
                    o1 = new HuffmanNode(this);
                }

                if (o1.SetNewValue(aDepth - 1, aValue) == true)
                {
                    return(true);
                }
            }

            return(false);
        }