예제 #1
0
 public EInteger GetCachedPower(EInteger bi)
 {
     if (bi.CanFitInInt32())
     {
         return(this.GetCachedPowerInt(bi.ToInt32Checked()));
     }
     lock (this.outputs) {
         for (var i = 0; i < this.size; ++i)
         {
             if (bi.Equals(this.inputs[i]))
             {
                 if (i != 0)
                 {
                     EInteger tmp;
                     // Move to head of cache if it isn't already
                     tmp            = this.inputs[i];
                     this.inputs[i] = this.inputs[0];
                     this.inputs[0] = tmp;
                     int tmpi = this.inputsInts[i];
                     this.inputsInts[i] = this.inputsInts[0];
                     this.inputsInts[0] = tmpi;
                     tmp             = this.outputs[i];
                     this.outputs[i] = this.outputs[0];
                     this.outputs[0] = tmp;
                     // Move formerly newest to next newest
                     if (i != 1)
                     {
                         tmp                = this.inputs[i];
                         this.inputs[i]     = this.inputs[1];
                         this.inputs[1]     = tmp;
                         tmpi               = this.inputsInts[i];
                         this.inputsInts[i] =
                             this.inputsInts[1];
                         this.inputsInts[1] = tmpi;
                         tmp             = this.outputs[i];
                         this.outputs[i] = this.outputs[1];
                         this.outputs[1] = tmp;
                     }
                 }
                 return(this.outputs[0]);
             }
         }
     }
     return(null);
 }
예제 #2
0
 public EInteger GetCachedPower(EInteger bi) {
   if (bi.CanFitInInt32()) {
     return this.GetCachedPowerInt(bi.ToInt32Checked());
   }
   lock (this.outputs) {
     for (var i = 0; i < this.size; ++i) {
       if (bi.Equals(this.inputs[i])) {
         if (i != 0) {
           EInteger tmp;
           // Move to head of cache if it isn't already
           tmp = this.inputs[i]; this.inputs[i] = this.inputs[0];
           this.inputs[0] = tmp;
           int tmpi = this.inputsInts[i]; this.inputsInts[i] =
           this.inputsInts[0]; this.inputsInts[0] = tmpi;
           tmp = this.outputs[i]; this.outputs[i] = this.outputs[0];
           this.outputs[0] = tmp;
           // Move formerly newest to next newest
           if (i != 1) {
             tmp = this.inputs[i]; this.inputs[i] = this.inputs[1];
             this.inputs[1] = tmp;
             tmpi = this.inputsInts[i]; this.inputsInts[i] =
             this.inputsInts[1]; this.inputsInts[1] = tmpi;
             tmp = this.outputs[i]; this.outputs[i] = this.outputs[1];
             this.outputs[1] = tmp;
           }
         }
         return this.outputs[0];
       }
     }
   }
   return null;
 }
예제 #3
0
 /// <include file='../../docs.xml'
 /// path='docs/doc[@name="M:PeterO.Cbor.CBORTypeFilter.TagAllowed(PeterO.Numbers.EInteger)"]/*'/>
 public bool TagAllowed(EInteger bigTag)
 {
     if (bigTag == null) {
     throw new ArgumentNullException("bigTag");
       }
       if (bigTag.Sign < 0) {
     return false;
       }
       if (this.any) {
     return true;
       }
       if ((this.types & (1 << 6)) == 0) {
     return false;
       }
       if (this.tags == null) {
     return true;
       }
       foreach (EInteger tag in this.tags) {
     if (bigTag.Equals(tag)) {
       return true;
     }
       }
       return false;
 }