예제 #1
0
 public void TransferOwnership(HVector source)
 {
     if (source == this)
     {
         return;
     }
     if (source != null && source.Dimension != this.Dimension)
     {
         throw new HVectorAccessException("Vector dimension mismatch");
     }
     this.Dispose();
     if (source == null)
     {
         return;
     }
     if (this.mDimension <= 0)
     {
         throw new HVectorAccessException("TransferOwnership not implemented for leaf");
     }
     this.mVector   = source.mVector;
     source.mVector = new List <HVector>();
     if (!this.IsDisposable())
     {
         return;
     }
     GC.ReRegisterForFinalize((object)this);
 }
예제 #2
0
 protected override bool EqualsImpl(HVector vector)
 {
     if (this.mDimension >= 1)
     {
         return(base.EqualsImpl(vector));
     }
     return(((HObjectVector)vector).O.TestEqualObj(this.O) != 0);
 }
예제 #3
0
 /// <summary>
 ///   Returns true if vector has same dimension, lengths, and elements
 /// </summary>
 public bool VectorEqual(HVector vector)
 {
     if (vector.GetType() != this.GetType())
     {
         return(false);
     }
     return(this.EqualsImpl(vector));
 }
예제 #4
0
 protected override bool EqualsImpl(HVector vector)
 {
     if (this.mDimension >= 1)
     {
         return(base.EqualsImpl(vector));
     }
     return((bool)((HTupleVector)vector).T.TupleEqual(this.T));
 }
예제 #5
0
        private static string BuildMessage(HVector sender, string sInfo)
        {
            string str = sInfo;

            if (sender != null)
            {
                str = "'" + str + "' when accessing '" + sender.ToString() + "'";
            }
            return(str);
        }
예제 #6
0
 protected HVector(HVector vector)
     : this(vector.Dimension)
 {
     if (this.mDimension <= 0)
     {
         return;
     }
     this.mVector.Capacity = vector.Length;
     for (int index = 0; index < vector.Length; ++index)
     {
         this.mVector.Add(vector[index].Clone());
     }
 }
예제 #7
0
 protected void InsertImpl(int index, HVector vector, bool clone)
 {
     if (this.mDimension < 1 || vector.Dimension != this.mDimension - 1)
     {
         throw new HVectorAccessException("Vector dimension mismatch");
     }
     if (index < 0)
     {
         throw new HVectorAccessException("Index out of range");
     }
     this.AssertSize(index - 1);
     lock (this.mVector)
         this.mVector.Insert(index, clone ? vector.Clone() : vector);
 }
예제 #8
0
        protected HVector ConcatImpl(HVector vector, bool append, bool clone)
        {
            if (this.mDimension < 1 || vector.Dimension != this.mDimension)
            {
                throw new HVectorAccessException("Vector dimension mismatch");
            }
            HVector hvector = append ? this : this.Clone();

            hvector.mVector.Capacity = this.Length + vector.Length;
            for (int index = 0; index < vector.Length; ++index)
            {
                hvector.mVector.Add(clone ? vector[index].Clone() : vector[index]);
            }
            return(hvector);
        }
예제 #9
0
 protected virtual bool EqualsImpl(HVector vector)
 {
     if (vector.Dimension != this.Dimension || vector.Length != this.Length)
     {
         return(false);
     }
     if (this.mDimension > 0)
     {
         for (int index = 0; index < this.Length; ++index)
         {
             if (!this[index].VectorEqual(vector[index]))
             {
                 return(false);
             }
         }
     }
     return(true);
 }
예제 #10
0
 internal HVectorAccessException(HVector sender, string sInfo, Exception inner)
     : base(HVectorAccessException.BuildMessage(sender, sInfo), (Exception)null)
 {
 }
예제 #11
0
 public HVector Insert(int index, HVector vector, bool clone)
 {
     this.InsertImpl(index, vector, clone);
     return(this);
 }
예제 #12
0
 public HVector Append(HVector vector, bool clone)
 {
     return(this.ConcatImpl(vector, true, clone));
 }
예제 #13
0
 /// <summary>Append vector to this vector</summary>
 public HVector Append(HVector vector)
 {
     return(this.ConcatImpl(vector, true, true));
 }
예제 #14
0
 public HVector Concat(HVector vector, bool clone)
 {
     return(this.ConcatImpl(vector, false, clone));
 }
예제 #15
0
 /// <summary>Concatenate two vectors, creating new vector</summary>
 public HVector Concat(HVector vector)
 {
     return(this.ConcatImpl(vector, false, true));
 }
예제 #16
0
 internal HVectorAccessException(HVector sender, string sInfo)
     : this(sender, sInfo, (Exception)null)
 {
 }
예제 #17
0
 internal HVectorAccessException(HVector sender)
     : this(sender, "Illegal operation on vector")
 {
 }
예제 #18
0
 /// <summary>Insert vector at specified index</summary>
 public HVector Insert(int index, HVector vector)
 {
     this.InsertImpl(index, vector, true);
     return(this);
 }