示例#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);
 }