[vtk-developers] Data structures in VTK

Simon Warfield warfield at bwh.harvard.edu
Tue Jan 1 08:35:28 EST 2002

Hi Will,

  A motivation for the standardization of the C++ Standard Template Library as 
a core part of the C++ language was the documentation of a standard interface 
for containers etc. which could be used and re-used across multiple projects.

  For example, if vtkDataArray was a vector<> everyone would know what 
operations were supported.  I am sure there are lots of good reasons
for an efficient implementation of dynamic arrays for basic types in VTK.

  But its not immediately obvious to me from
that I could make a vtkDataArray let me keep a dynamic array of pointers to
a new type I might want such as a struct {...} or class instance, whereas I 
know I can define a vector<> of any type I want.

  Based on the naming of vtkDataArray, I don't see a vtkDataHash or a 

  STL has a lot of quirks, and vendors used to do a poor job of implementing it,
since the C++ standard was only ratified in 1998 after 9 years of work.  Perhaps
its still not suitable for VTK.  But now its several years since the 
standard was ratified, freely available portable implementations of STL exist
and work with many compilers on many platforms.  

VTK might be able to use one of these STL implementations, or perhaps its better
for VTK to not change from what is currently done, or perhaps its worthwhile
for developers using VTK to re-implement a portable container collection.

Which ever of the above is the case, I think it is beneficial to revisit the 
assumptions that were made when the original design decisions were made and
see if they are still valid.

On Mon, Dec 31, 2001 at 02:31:46PM -0500, Will Schroeder wrote:
> Hi Andy-
> vtkDataArrays are dynamic arrays. We already have these.
> Will
> At 11:20 AM 12/31/2001 -0500, Andy Cedilnik wrote:
> >Hello!
> >
> >I don't think some primitive containers are too difficult to write. I mean 
> >the hash
> >tables and lists that are scattered around VTK tree were probably written in
> >short amount of time anyway. Let us start selectively and add these classes
> >to VTK. I suggest we brainstorm the interface that will fulfill 
> >everybody's needs.
> >
> >So, for example, I need this in a dynamic array:
> >
> >Find(x) // finds element x
> >Insert(i, x) // inserts element x at position i
> >Append(x)  // appends element x
> >Prepend(x) // prepend element x
> >Remove(i) // remove's element at position i
> >Clean() // removes all elements
> >Size() // returns number of elements
> >RealSize() // returns size of internal array
> >
> >The find is tricky, because you need a comparison function.
> >All other methods are pretty trivial.
> >Some other methods:
> >Sort(i,j) // Sorts the range between i and j
> >Remove(j,j) // Remove range between i and j
> >Reverse(j,j) // Reverse range between i and j
> >
> >and so on. You get the picture.
> >
> >I vote for developing our own containers. We could potentially use similar 
> >interface as STL.
> >
> >                                         Andy
> _______________________________________________
> vtk-developers mailing list
> vtk-developers at public.kitware.com
> http://public.kitware.com/mailman/listinfo/vtk-developers


More information about the vtk-developers mailing list