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. 2 2092
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
"Tomas Restrepo \(MVP\)" <to****@mvps.or g> wrote in message news:<#g******* *******@TK2MSFT NGP14.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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 needs to be of that type, and not a List<BaseClass>. However, I
need to cast that list to a List<BaseClass> and it is not working. The
code is below. I get the following exception:
"Unable to cast object of type 'System.Collections.Generic.List`1' to
type 'System.Collections.Generic.List`1'."
...
|
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 constructor if necessary (or I can supply an instance
for the copy constructor).
For example:
C++
vector<classvClass;
|
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, what's the best practise for
returning a private List<as a property.
Consider the example below, the class "ListTest" contains a private "List<>"
called "strings" - it also provides a public method to add to that list,
|
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
support random access, allows forward and reverse traversal and
natively supports sorting, i.e., STL's list<T>. There isn't even a set of
algorithms that would allow me to easily sort a generic collection.
System.Array has a robust set of static algorithms, why not extend this to
ICollection?
|
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 (is that called weakly typed?), I would assume List<is far
better. So, why do people use ArrayList so often? Am I missing
somehing? What's the difference between them?
Zytan
| |
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 deleted.
But, the loop ending condition must be checked on each iteration,
since the Count changes as you delete elements. I would think it is
guaranteed to be computed each time, and not cached.
So, is this the best way?
|
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 variable"
and I have no idea why! Do lists return copies of their elements?
Why can't I change the element itself?
class Program
{
private struct MyStruct
|
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), whereas List<>.Clear removes all items from the list.
That part makes a reasonable amount of sense, as you can't actually take
items away from an Array. However, there doesn't seem to be a way to
perform the same operation in one fell swoop on a List<>.
For example:
|
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 well, but I am having trouble with generic lists, like
List<char>.
What I have working is :
Type type = newObj.GetType(); //newObj is what I'm trying to dump
|
by: paul.gibson |
last post by:
A simple code example is easier than trying to describe the issue. I
have:
public class myClassA
{
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |