This project has moved and is read-only. For the latest updates, please go here.

Subclass Privs on Vector<T>

Sep 15, 2011 at 6:40 PM

I have a real-time application that needs to "grow" a data series in a Vector  (i.e. some double[] is allocated > initial size and Count is adjusted as the vector grows).  

Basically data arrives on some high sampling frequency, is added to a vector or vectors.   The vector may start with 0 elements and grow in single units from one event to the next.  Calculations are done using those vectors after appending a new sample to the vector.

Hence, I started by implemented a subclass of Vector<T> that implements an expandable vector.   I ran into the following problems:

  1. the Count property setter is declared private rather than protected
  2. the ctor checks for Count > 0

Could the distribution be modified to relax Count privs and the ctor check?   Is there any direct usage of Vector<T>.Data.Length in algorithms as opposed to Vector<T>.Count?   If Data.length is used where Count < Length would be a problem.

p.s. The cost of creating a new precisely sized vector on each invocation would be prohibitively costly.