Ejemplo n.º 1
0
Archivo: ItcId.cs Proyecto: weeble/ohos
 public override ItcId Sum(ItcId aOther)
 {
     if (aOther != Zero)
     {
         throw new Exception("Over unity.");
     }
     return this;
 }
Ejemplo n.º 2
0
Archivo: ItcId.cs Proyecto: weeble/ohos
 public static ItcId Tree(ItcId aLeft, ItcId aRight)
 {
     if (aLeft == One && aRight == One)
     {
         return One;
     }
     if (aLeft == Zero && aRight == Zero)
     {
         return Zero;
     }
     return new ItcIdTree(aLeft, aRight);
 }
Ejemplo n.º 3
0
 public override ItcEvent Grow(ItcId aId, out long aCost)
 {
     if (aId == ItcId.One)
     {
         aCost = 0;
         return Single(iValue + 1);
     }
     long cost;
     ItcEvent evPrime = new ItcEventTree(iValue, Zero, Zero).Grow(aId, out cost);
     aCost = cost + GrowConstant;
     return evPrime;
 }
Ejemplo n.º 4
0
 internal override ItcEvent Fill(ItcId aLeft, ItcId aRight)
 {
     if (aLeft == ItcId.One)
     {
         ItcEvent rightPrime = aRight.Fill(iRight);
         return Tree(
             iValue,
             Single(Math.Max(iLeft.Max, rightPrime.Min)),
             rightPrime);
     }
     if (aRight == ItcId.One)
     {
         ItcEvent leftPrime = aLeft.Fill(iLeft);
         return Tree(
             iValue,
             leftPrime,
             Single(Math.Max(iRight.Max, leftPrime.Min)));
     }
     return Tree(
         iValue,
         aLeft.Fill(iLeft),
         aRight.Fill(iRight));
 }
Ejemplo n.º 5
0
            public ItcEvent InternalGrow(ItcId aLeft, ItcId aRight, out long aCost)
            {
                long costLeft, costRight;
                ItcEvent growLeft, growRight;

                if (aRight != ItcId.Zero)
                {
                    growRight = iRight.Grow(aRight, out costRight);
                }
                else
                {
                    growRight = null;
                    costRight = long.MaxValue;
                }

                if (aLeft != ItcId.Zero)
                {
                    growLeft = iLeft.Grow(aLeft, out costLeft);
                }
                else
                {
                    growLeft = null;
                    costLeft = long.MaxValue;
                }

                Debug.Assert(growLeft != null || growRight != null);

                if (costLeft < costRight)
                {
                    aCost = costLeft + 1;
                    return Tree(iValue, growLeft, iRight);
                }
                aCost = costRight + 1;
                return Tree(iValue, iLeft, growRight);
            }
Ejemplo n.º 6
0
 public override ItcEvent Grow(ItcId aId, out long aCost)
 {
     return aId.InternalGrow(this, out aCost);
 }
Ejemplo n.º 7
0
 internal ItcStamp(ItcId aId, ItcEvent aEvent)
 {
     iId = aId;
     iEvent = aEvent;
 }
Ejemplo n.º 8
0
Archivo: ItcId.cs Proyecto: weeble/ohos
 public override void Split(out ItcId aLeft, out ItcId aRight)
 {
     if (Zero == iLeft)
     {
         ItcId sub1, sub2;
         iRight.Split(out sub1, out sub2);
         aLeft = Tree(Zero, sub1);
         aRight = Tree(Zero, sub2);
     }
     else if (Zero == iRight)
     {
         ItcId sub1, sub2;
         iLeft.Split(out sub1, out sub2);
         aLeft = Tree(sub1, Zero);
         aRight = Tree(sub2, Zero);
     }
     else
     {
         aLeft = Tree(iLeft, Zero);
         aRight = Tree(Zero, iRight);
     }
 }
Ejemplo n.º 9
0
 public ItcEvent Grow(ItcId aId)
 {
     long ignore;
     return Grow(aId, out ignore);
 }
Ejemplo n.º 10
0
Archivo: ItcId.cs Proyecto: weeble/ohos
 public abstract ItcId Sum(ItcId aOther);
Ejemplo n.º 11
0
Archivo: ItcId.cs Proyecto: weeble/ohos
 public abstract void Split(out ItcId aLeft, out ItcId aRight);
Ejemplo n.º 12
0
Archivo: ItcId.cs Proyecto: weeble/ohos
 public override ItcId Sum(ItcId aOther)
 {
     return aOther;
 }
Ejemplo n.º 13
0
Archivo: ItcId.cs Proyecto: weeble/ohos
 public override void Split(out ItcId aLeft, out ItcId aRight)
 {
     aLeft = Zero;
     aRight = Zero;
 }
Ejemplo n.º 14
0
Archivo: ItcId.cs Proyecto: weeble/ohos
 public override ItcId Sum(ItcId aOther)
 {
     if (Zero == aOther)
     {
         return this;
     }
     if (One == aOther)
     {
         throw new Exception("Over unity.");
     }
     var otherTree = (ItcIdTree) aOther;
     return Tree(iLeft.Sum(otherTree.iLeft), iRight.Sum(otherTree.iRight));
 }
Ejemplo n.º 15
0
 internal override ItcEvent Fill(ItcId aLeft, ItcId aRight)
 {
     return this;
 }
Ejemplo n.º 16
0
 public abstract ItcEvent Grow(ItcId aId, out long aCost);
Ejemplo n.º 17
0
Archivo: ItcId.cs Proyecto: weeble/ohos
 public override void Split(out ItcId aLeft, out ItcId aRight)
 {
     aLeft = Tree(One, Zero);
     aRight = Tree(Zero, One);
 }
Ejemplo n.º 18
0
 internal abstract ItcEvent Fill(ItcId aLeft, ItcId aRight);
Ejemplo n.º 19
0
Archivo: ItcId.cs Proyecto: weeble/ohos
 public ItcIdTree(ItcId aLeft, ItcId aRight)
 {
     iLeft = aLeft;
     iRight = aRight;
 }