"NotABug" <No*****@discussions.microsoft.com> wrote:
Is it possible to do collections of struct __values in MC++ 2003?
see __box( )
Thanks. But I think that would create a lot of overhead no?
For any manipulation, the structure seems to be copied bytewise in and out
of the CLR memory..... but maybe is the only way...
What would be the best way in terms of performance for storing big
collections of small data structures in Managed C++, like Colors or Points?
If you wish to expose a collection of value types to other .NET
applications, you have two choices:
1. Use an array. Arrays of value types use internal storage, and so are more
space- and time-efficient for small types. To learn more about this option,
take a look at
http://msdn.microsoft.com/library/de...et6_update.asp
2. Use boxing, as Carl suggested. For more complex data structures, the
overhead of the data structure may exceed the overhead of the boxing in any
case.
On the other hand, if the collection is entirely internal to your
application, you'll probably get the best performance out of STL containers,
which specialize their implementations to your value types. You could even
wrap an STL container in a public managed class to form a restricted
interface to your collection for other .NET applications.
If none of these approaches seem to apply to you, could you give some more
information about your specific situation, such as the type of container you
need and whether you intend to share it? I hope this helps.
--
Derrick Coetzee, Microsoft Speech Server developer
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included code samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm