472,353 Members | 2,138 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

List<t> generic type - Fastest way to copy into an unmanaged array?

Hi, Im hoping someone can give me some advice.
Im doing some development using VS Whidbey 2005 beta 1.

Im about to implement some highly time critical code related to a
managed collection of floats.

I basically require the fastest way to convert a managed array of
floats into an unmanaged array of floats.

As far as the managed collection is implemented, ive read that the
following would be the most type-safe and efficient (no
boxing/unboxing):

List<float> myFloats

However, Ive also read that the Marshal.Copy method is an extremely
fast way of copying a tradional managed array into an unmanaged array.
But if i do this method (i,e use a tradional .net array), I have the
boxing/unboxing issues.

For this particular case, I must sacrifice all I can for conversion
speed.

Can anyone recommend the fastest way to store and convert an array of
floats (managed -> unmanaged)?

thanks for reading.
Nov 17 '05 #1
2 1994
Daniel,
Hi, Im hoping someone can give me some advice.
Im doing some development using VS Whidbey 2005 beta 1.

Im about to implement some highly time critical code related to a
managed collection of floats.

I basically require the fastest way to convert a managed array of
floats into an unmanaged array of floats.

As far as the managed collection is implemented, ive read that the
following would be the most type-safe and efficient (no
boxing/unboxing):

List<float> myFloats

However, Ive also read that the Marshal.Copy method is an extremely
fast way of copying a tradional managed array into an unmanaged array.
It is indeed.
But if i do this method (i,e use a tradional .net array), I have the
boxing/unboxing issues.


Huh? Why boxing here? As long as you use an array of float, you won't need
boxing/unboxing. Granted, you'll end up copying a value here and there from
the stack to the managed heap where the array is stored, but it definitely
does *not* imply boxing at all (unless you for some reason declare the array
as Object* __gc[], which you probably aren't doing).

--
Tomas Restrepo
to****@mvps.org

Nov 17 '05 #2
"Tomas Restrepo \(MVP\)" <to****@mvps.org> wrote in message news:<#g**************@TK2MSFTNGP14.phx.gbl>...
Daniel,
Hi, Im hoping someone can give me some advice.
Im doing some development using VS Whidbey 2005 beta 1.

Im about to implement some highly time critical code related to a
managed collection of floats.

I basically require the fastest way to convert a managed array of
floats into an unmanaged array of floats.

As far as the managed collection is implemented, ive read that the
following would be the most type-safe and efficient (no
boxing/unboxing):

List<float> myFloats

However, Ive also read that the Marshal.Copy method is an extremely
fast way of copying a tradional managed array into an unmanaged array.


It is indeed.
But if i do this method (i,e use a tradional .net array), I have the
boxing/unboxing issues.


Huh? Why boxing here? As long as you use an array of float, you won't need
boxing/unboxing. Granted, you'll end up copying a value here and there from
the stack to the managed heap where the array is stored, but it definitely
does *not* imply boxing at all (unless you for some reason declare the array
as Object* __gc[], which you probably aren't doing).

You're quite right. I mis-read documentation on array and collection
type boxing/unboxing.

Thankyou for your assistance.
Regards.
Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: matty.hall | last post by:
I have two classes: a base class (BaseClass) and a class deriving from it (DerivedClass). I have a List<DerivedClass> that for various reasons...
6
by: Jeff.Boeker | last post by:
I'm learning a lesson in how I need to be more specific :) In C++ I can resize a vector and it will allocate memory and it will call the default...
9
by: Paul | last post by:
Hi, I feel I'm going around circles on this one and would appreciate some other points of view. From a design / encapsulation point of view,...
0
by: Iron Moped | last post by:
I'm airing frustration here, but why does LinkedList<not support the same sort and search methods as List<>? I want a container that does not...
44
by: Zytan | last post by:
The docs for List say "The List class is the generic equivalent of the ArrayList class." Since List<is strongly typed, and ArrayList has no type...
56
by: Zytan | last post by:
Obviously you can't just use a simple for loop, since you may skip over elements. You could modify the loop counter each time an element is...
45
by: Zytan | last post by:
This returns the following error: "Cannot modify the return value of 'System.Collections.Generic.List<MyStruct>.this' because it is not a...
35
by: Lee Crabtree | last post by:
This seems inconsistent and more than a little bizarre. Array.Clear sets all elements of the array to their default values (0, null, whatever),...
2
by: Fred Mellender | last post by:
I am trying to use reflection to output the fields (names and values) of an arbitrary object -- an object dump to a TreeView. It works pretty...
11
by: paul.gibson | last post by:
A simple code example is easier than trying to describe the issue. I have: public class myClassA {
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.