예제 #1
0
        internal void UpdateVectorElement( VectorValueRec Rec )
        {
            try
            {
            for( int Count = 0; Count < VectorValuesArrayLast; Count++ )
              {
              if( Rec.Prime == VectorValuesArray[Count].Prime )
            {
            VectorValuesArray[Count] = Rec;
            return;
            }
              }

            VectorValuesArray[VectorValuesArrayLast] = Rec;
            VectorValuesArrayLast++;
            if( VectorValuesArrayLast >= VectorValuesArray.Length )
              Array.Resize( ref VectorValuesArray, VectorValuesArray.Length + IncreaseArraySizeBy );

            }
            catch( Exception Except )
              {
              throw( new Exception( "Exception in ExponentVectorNumber.UpdateVectorElement(): " + Except.Message ));
              }
        }
예제 #2
0
        internal void SetFromDelimString( string InString )
        {
            try
            {
            SetToZero();
            string[] SplitS = InString.Split( new Char[] { ':' } );
            for( int Count = 0; Count < SplitS.Length; Count++ )
              {
              string[] SplitVal = SplitS[Count].Split( new Char[] { ';' } );
              if( SplitVal.Length < 2 )
            break;

              VectorValueRec Rec = new VectorValueRec();
              Rec.Prime = (uint)Int32.Parse( SplitVal[0] );
              Rec.Exponent = (uint)Int32.Parse( SplitVal[1] );
              VectorValuesArray[VectorValuesArrayLast] = Rec;
              VectorValuesArrayLast++;
              if( VectorValuesArrayLast >= VectorValuesArray.Length )
            Array.Resize( ref VectorValuesArray, VectorValuesArray.Length + IncreaseArraySizeBy );

              }
            }
            catch( Exception Except )
              {
              throw( new Exception( "Exception in ExponentVectorNumber.SetFromDelimString(): " + Except.Message ));
              }
        }
예제 #3
0
        /*
          internal void RemoveRecord( uint Prime )
        {
        int MoveTo = 0;
        for( int Count = 0; Count < VectorValuesArrayLast; Count++ )
          {
          if( VectorValuesArray[Count].Prime != Prime )
        {
        VectorValuesArray[MoveTo] = VectorValuesArray[Count];
        MoveTo++;
        }
          }

        VectorValuesArrayLast = MoveTo;

        // This is the same as dividing, so it would leave it
        // at 1 if if divided out everything.
        if( MoveTo == 0 )
          SetToOne();

        }
        */
        internal VectorValueRec GetValueRecordAt( int Index )
        {
            if( Index >= VectorValuesArrayLast )
              {
              VectorValueRec Rec = new VectorValueRec();
              return Rec; // With Prime set to zero.
              }

            return VectorValuesArray[Index];
        }
예제 #4
0
        /*
          internal void AddOneVectorElement( uint Prime, uint ExpToAdd )
        {
        try
        {
        for( int Count = 0; Count < VectorValuesArrayLast; Count++ )
          {
          if( VectorValuesArray[Count].Prime == Prime )
        {
        VectorValuesArray[Count].Exponent += ExpToAdd;
        return;
        }
          }

        // If it wasn't found, make a new one.
        VectorValueRec Rec = new VectorValueRec();
        Rec.Prime = Prime;
        Rec.Exponent = ExpToAdd;
        VectorValuesArray[VectorValuesArrayLast] = Rec;
        VectorValuesArrayLast++;
        if( VectorValuesArrayLast >= VectorValuesArray.Length )
          Array.Resize( ref VectorValuesArray, VectorValuesArray.Length + IncreaseArraySizeBy );

        }
        catch( Exception Except )
          {
          throw( new Exception( "Exception in ExponentVectorNumber.AddOneVectorElement(): " + Except.Message ));
          }
        }
        */
        internal VectorValueRec GetVectorElement( uint Prime )
        {
            for( int Count = 0; Count < VectorValuesArrayLast; Count++ )
              {
              if( Prime == VectorValuesArray[Count].Prime )
            return VectorValuesArray[Count];

              }

            // Didn't find a match.
            VectorValueRec Rec = new VectorValueRec();
            Rec.Prime = Prime;
            Rec.Exponent = 0;
            return Rec;
        }
예제 #5
0
        internal void AddOneFastVectorElement( uint Prime )
        {
            try
            {
            VectorValueRec Rec = new VectorValueRec();
            Rec.Prime = Prime;
            Rec.Exponent = 1;
            VectorValuesArray[VectorValuesArrayLast] = Rec;
            VectorValuesArrayLast++;
            if( VectorValuesArrayLast >= VectorValuesArray.Length )
              Array.Resize( ref VectorValuesArray, VectorValuesArray.Length + IncreaseArraySizeBy );

            }
            catch( Exception Except )
              {
              throw( new Exception( "Exception in AddOneFastVectorElement(): " + Except.Message ));
              }
        }