ArrayList without Boxing and UnBoxing

J

Jon Skeet [C# MVP]

Peter Olcott said:
Yes, but, this issue will remain unresolved until I know for sure. One of the
rules that I strictly enforce is never make any assumptions. How could the
answer to this question be empirically verified?

Compile a simple test app, run it under cordbg, and look at the
assembly generated.

You'll need to turn optimisations on everywhere though.
 
P

Peter Olcott

Jon Skeet said:
Compile a simple test app, run it under cordbg, and look at the
assembly generated.

Is it possible to look at the actual Intel specific assembly language?
 
J

Jon Skeet [C# MVP]

Peter Olcott said:
Is it possible to look at the actual Intel specific assembly language?

Absolutely. It's not the easiest tool to get the hang of, but it's not
too bad after a bit of playing.
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

Jeff said:
Just to be clear, I believe std::vector is finally available in C++/CLI.

When has it not been ?

It seems to work (for a very simple example) in both
7.1/2003 and 8.0/2005.

Arne
 
P

Peter Olcott

Willy Denoyette said:
But, std::vector is a STL container, not a managed STL (now officially named
STL/CLR) container, and these were available since VC6.
Note that STL/CLR is now scheduled for ORCAS.

It is scheduled for killer whales?
 
P

Peter Olcott

I would suppose that managed STL is not directly available from C#, and only
available from C++, right?
 
W

Willy Denoyette [MVP]

Peter Olcott said:
I would suppose that managed STL is not directly available from C#, and only available from
C++, right?

The primary target is C++/CLI, but the STL/CLR containers can be operated on from any
managed language, like this:.

public ref class DataEngine {
public: ...
System::Collections::Generic::ICollection<int>^ GetDataContainer()
{
return m_data;
}
private:
cliext::vector<int>^ m_data; // a STL/CLR vector
};

//C# consumer
...
m_DataEng = new DataEngine();
ICollection<int> iColl = m_DataEng.GetDataContainer();
foreach (Object objCur in iColl)
{ ... }

Willy.
 
B

Bruce Wood

Peter said:
It looks like you have found the best possible solution to every aspect of my
original question. I am assuming that generics are equivalent to C++ templates
so that this solution could be adapted to become a generic solution. I am
assuming by what you said that C# does not have the equivalent the [inline]
keyword.

After all of this back-and-forth about array access speed....

You DO realize that C# is a garbage-collected language, like Java, and
that at any time the GC can decide to kick in and do garbage
collection?

I know that people DO use C# for real-time applications, so you may
want to read up on how they ensure that particular paths through the
code (which are the paths with real-time deadlines to meet) aren't
interrupted by the GC.
 
P

Peter Olcott

Bruce Wood said:
Peter said:
It looks like you have found the best possible solution to every aspect of my
original question. I am assuming that generics are equivalent to C++
templates
so that this solution could be adapted to become a generic solution. I am
assuming by what you said that C# does not have the equivalent the [inline]
keyword.

After all of this back-and-forth about array access speed....

You DO realize that C# is a garbage-collected language, like Java, and
that at any time the GC can decide to kick in and do garbage
collection?

I know that people DO use C# for real-time applications, so you may
want to read up on how they ensure that particular paths through the
code (which are the paths with real-time deadlines to meet) aren't
interrupted by the GC.
I would think that this might be something like forcing GC before you enter the
time critical path? I don't think that GC will be a problem for my most time
critical operation. For this operation I know the required size in advance for
the operation requiring the largest amount of memory, and the other operations
need so little memory that I could allocate the maximum required of this memory
in advance too, if I have to.

I will implement the original solution in unmanaged C++. Because of all of the
help that I have received here it looks like I will be able to transform this
original solution into a .NET implementation. In other words the .NET
architecture has passed the required feasibility tests. It looks like .NET can
provide the required performance, one way or another.

Also I just went back and reviewed, the help that you provided was apparently
the most useful of all help that was provided, thanks again.
 
J

Jeff Louie

Willy... I must very dense. I thought the OP was trying to write in
managed code
using patterns that he was familiar with such as the STL. I was trying
to point
out that his knowledge base in STL is still valuable and that this
knowledge can
be utilized in writing managed code if uses managed STL.

Regards,
Jeff
But, std::vector is a STL container, not a managed STL (now officially
named
STL/CLR) container, and these were available since VC6.<
 
P

Peter Olcott

Jeff Louie said:
Willy... I must very dense. I thought the OP was trying to write in
managed code
using patterns that he was familiar with such as the STL. I was trying
to point
out that his knowledge base in STL is still valuable and that this
knowledge can
be utilized in writing managed code if uses managed STL.

That info was very useful too, thanks. I might do it that way with STL.
 
W

Willy Denoyette [MVP]

Jeff Louie said:
Willy... I must very dense. I thought the OP was trying to write in
managed code
using patterns that he was familiar with such as the STL. I was trying
to point
out that his knowledge base in STL is still valuable and that this
knowledge can
be utilized in writing managed code if uses managed STL.

Regards,
Jeff
named
STL/CLR) container, and these were available since VC6.<

Jeff,
I don't see a reason to be dense, in your reply to Arne:
Just to be clear, I believe std::vector is finally available in
C++/CLI.

I noticed the "finally", and that's why I said that std:vector is a native STL container,
which is available in all versions of VC++ since VC6. Don't know why you did use *finally*
here, really.

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top