|
OT: You may want to be a little careful with the usage of language in a help forum, using wording like "I expect" sounds far too much like "I want this done for me", not as it should sound "I would like some help with this please" - the sentiment expressed in the last line of your post.
Anyhoo, It sounds to me like the functionality you are after is closer to a Binary tree than it is to a multidimensional array, maybe its worth you googling that and having a look.
Failing that would continuing with a M.D. ArrayList format encapsulated into an easy-to-use object not fit the bill?
|
|
|
|
|
Hello, J4amieC.
Probably, I've formulated what I wanted to say in a very inadequate way, by "I expect the following functionality from the implementation:" I meant "I would like to use the result solution for following purposes:". I do not want anyone to write code for me, I would like to hear some thoughts of people that are more experienced in this topic as I am.
Concerning your solution: at first, thank you for your help. Secondly, I'm afraid that I don't quite understand what you're proposing. I know what a binary tree is, what kind of data do you suggest to store in the nodes of the tree? Besides, I think it will be better to store minimum data for access to array (in your example with binary tree, I will need some kind of "links" to the children of parent node). I would like to give some estimation of typical "spaces" that are currently used. For example, a typical 10-dimensional array with following dimensions: {4, 7, 8, 6, 8, 2, 6, 7, 2, 7}. This will result (let's take 8 byte pro double-value) in
(4*7*8*6*8*2*6*7*2*7)*8 bytes=101154816 bytes=96,46875 Mb. And that is already quite big. I can have up to 10-20 of those "spaces". I just cannot throw away another 96 Mb for control structures. And of course Arraylist-based solution will not save the situation because of memory- and time overhead connected with boxing/unboxing.
Here is also the code with which I tested the performance. I've commented it as much as possible, but if anything is not clear, please, do not hesitate to ask:
//Create a test 10-dimensional array
int[] allDimensions = new int[10]{4, 7, 8, 6, 8, 2, 6, 7, 2, 7};
System.Array testArray = Array.CreateInstance(System.Type.GetType("System.Double"), allDimensions);
//currentDimensions is an array representing "counters" of dimensions
//I'll explain this on example. If as tempTable we have a three-dimensional array
//with allDimensions=[4, 8, 2].
//Then currentDimensions will run through the following combinations:
//[0; 0; 0], [1; 0; 0], [2; 0; 0], [3; 0; 0], [0; 1; 0], [1; 1; 0], [2; 1; 0] etc.
int[] currentDimensions = new int[allDimensions.Length];
//done variable checks whether all "places" of the space were visited
//(i.e. with the same example of three-dimensional array bool will be true when
//currentDimensions=[3, 7, 1]
bool done=false;
while(!done)
{
//Increment the current place in the space
double curValue = (double)testArray.GetValue(currentDimensions);
testArray.SetValue(++curValue, currentDimensions);
//Try to get the next combination of currentDimensions
done=true;
for(int j=0; j
|
|
|
|
|
I'm developing my first Managed DirectX app at the minute and although this isn't going to stop me moving on it might change my design ideas. All i want to know is which is quicker/more efficient after it's compiled.
Scenario 1.
public class Ball
{
public void DrawBall
{
}
}
public class Game
{
Ball ball = new Ball();
public void Draw()
{
ball.DrawBall();
}
}
or Scenario 2
public class Ball{}
public class Game
{
Ball ball = new Ball();
public void Draw()
{
}
}
So, which is faster or are they both the same speed?
Both will have the same draw code but scenario 1 does the drawing inside the ball.DrawBall method which is called from the class game.
Scenario 2 does the drawing inside the game class so there isn't the extra function call.
Bear in mind that this is gonna be done over 100 times a frame (potentially) and around 30 frames per second.
Hope someone out there knows.
Kev
|
|
|
|
|
I think this is more of a design structure question than a performance question. Imagine you have the scenario where you're drawing 2 teams of 11 players, a ball and 2 goals, would you want your code to look like this:
public class Game
{
public void Draw()
{
}
}
or this
public class Game
{
private Ball ball;
private Team team1;
private Team team2;
private Gaol goal1;
private Gaol goal2;
public void Draw()
{
ball.Draw();
team1.Draw();
team2.Draw();
goal1.Draw();
gaol2.Draw();
}
}
I dont know which is quicker, but for readability and to save having a very long method/list of methods in the game class I would go with the second option above.
|
|
|
|
|
I know that, i would rather use the second option myself, but the question is all about speed. If there is no speed difference then i will go with the more OO oriented approach because it's easier, but if it's slower then i will have to use the less readable first option.
Kev
|
|
|
|
|
If you are that concerned about speed why not write it in assembler?
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|
|
2 Reasons.
1. I don't know assembler
2. That would defeat the object of me trying to learn Managed DirectX
Kev
|
|
|
|
|
why not loop through it 10^6 times to see which is faster?
there are no facts, only interpretations
|
|
|
|
|
second source is faster than first..
why ?
because in second source, construction operation is automated..
Oguz Bastemur
|
|
|
|
|
Hi,
We currently have a sutuation where we have a C# application and a MFC/C++ application.
To synchronize events between them we have used a Mutex. This is created with the following code:
mutexInterface = new System.Threading.Mutex(false, strMUTEX);
strMUTEX is a constant string used to name the Mutex.
On the MFC side the mutex is constructed with the following code:
m_muxInterfaceMutex(FALSE, strMUTEX);
Everything seems pretty simple so far.
If we start the MFC app first, then the C# one everything runs fine.
However if we run the C# app first the construction of the mutex in the MFC app fails and displays 'A required resource was unavailable'
Does anybody know how we can overcome this situation. We would rather avoid telling the users they have to start one app before the other, but it may come to that.
|
|
|
|
|
sjhart wrote:
We would rather avoid telling the users they have to start one app before the other, but it may come to that.
You could write a 3rd application/tiny script that starts both applications in the desired order you want them to be started.
--
Affordable Windows-based CMS: www.zeta-producer.de/enu
|
|
|
|
|
Do someone know a simple way to hook 2 forms to each other like winamp ?
I have a SDI application with a parent form from which i open child forms.
For example, in winamp there is the main window which is the player, then we can open the playlist.
We can move the playlist and put it where we want, but if we move it near the main window, it automaticaly sticks to it (like a magnet) then after, when we move the player, the playlist follow...
I would like my forms to do this magnet effect.
thanks
|
|
|
|
|
There is obviously no built-in way of doing this but you can always:
- keep track of where your forms are and the sizes of the forms
- respond to events when a form is moved
- calculate whether a form is close enough to "snap" and then move the form...
This posting is provided "AS IS" with no warranties, and confers no rights.
Alex Korchemniy
|
|
|
|
|
Hi,
my problem is, that if I want to change the row by pressing the return key, I found no event which fired.
I have added the DataGridTextBoxColumn to my DataGrid and so I have the possibility to add events on several columns.
Does anybody know a solution?
Sorry, if my English was not perfect, I am from Germany.
Thanx
Steffen
|
|
|
|
|
Because your problem is not very clear to me, I assume that your datagrid's data source is from a dataset.
You can try set an event handler for one of these dataset events.
1. RowChanged
2. RowChanging
3. ColumnChanged
4. ColumnChanging
For the changing event, it occurs when data is changing. You can cancel or accept the changes in this event.
For the changed event, it occurs when data has been changed successfully.
|
|
|
|
|
I mean with change the row not to change the value in the special cell. I mean that the cursor is after pressing the return key in the row below the row before.
Example:
Rows:
0
1*cursor* -> then pressing return --> event should fire
2
-->
0
1
2*cursor* (one position higher in the row collection)
I hope my English was understandable.
|
|
|
|
|
Hello,
I'm looking for a C# parser that can give me access to a C# program's code inside a running C# program. The parser should not just build an abstract syntax tree but also give a types hierarchy of the types created and used in the program and some further refinements. For example, it would be important to know the type of an object if an object's method is called. (the highest type in an inheritance hierarchy would be enough, of course).
Does anyone know about a library providing this? I only found some pure parsers that give me an AST. But with the tree alone there's much more work to do to get the required information out of the program.
Thanks
Stefan
|
|
|
|
|
|
I think reflection is not capable of getting information about the inside of a method. I need t know which classes' methods are called by a method. I want to create a call/use graph from a software (can be from source code).
|
|
|
|
|
|
Ok, I'm missing something fundamental here - I know it. Would one of you gurus be so kind as to point out my error, please.
I have a class Called ProcessInfo in the namespace Mycompany.Project that is used to store custom process information...
namespace MyCompany.Project
{
public class ProcessInfo
{
private string m_sStatus;
.
.
.
}
}
This class is used in two projects. Project A is a dll that uses the same (MyCompany.Project) namespace. Project B is an exe also uses the same namespace.
Project B dynamically loads and invokes the Project A dll. Project B passes an instance of an ArrayList to Project A, who adds instances of the ProcessInfo class to the ArrayList. Project B attempts to loop through the ArrayList to access the ProcessInfo instances as follows:
private void SomeFunction()
{
foreach (ProcessInfo oInfo in oArrayList)
{
.
.
.
}
}
I always get invalid cast exceptions on the foreach line. The debugger correctly show the oArrayList as containing instances of type {MyCompany.Project.ProcessInfo} and the contents of the individual ArrayList entries can be read (in the debugger).
What am I missing? I've tried various permutations of the above code - including fully qualifying the namespace, using IEnumerator, etc...
I have searched MSDN, but have had little luck specifying the correct query to find answers.
I would very much appreciate any help in solving this. I thank you in advance.
Peff
|
|
|
|
|
I want to retrieve the VID and PID of usb device,such as mp3 and u-disk.I know how to enum the device infomation by using some of windows API step by step.I just do not know how to define the GUID structure,how to pass the GUID as a parameter to the api,such as SetupDiGetClassDevs(),and especially how to marshal the type of those parameters.
Can you give me an detail example in C#?
|
|
|
|
|
Hi guys
Is there any way that I can set the small/large imagelists for a ListView control to the handle of the system's standard image list?
I know I can use SHGetFileInfo() function for retreiving the system image list, but how do I set it to ListView.SmallImageList? (ie. ListView.SmallImageList.Handle is READ-ONLY)
Any pointers would be appreciated
Thanks
|
|
|
|
|
Hi,
I'm trying to implement cd burning capabilities in my application with the open source console application cdrdao[^].
I'd like to run this application in the background (hidden from the user), but return all the status information "on the fly" to the user. That is, before cdrdao has terminated burning the cd.
How can I monitor what this console application is writing to the console? Also, would it be possible to simulate keystrokes in the console application, but from my code? For example, if the user clicks the Cancel button, I'd like to send a CTRL-BREAK to the console app.
Thanks!
Carl
|
|
|
|
|
Carl,
You might want to look at the System.Diagnostics.ProcessStartInfo class. The ProcessStartInfo class allows the redirecting of the standard output so that the calling application can read it. For example:
{
.
.
.
Process oProcess = new Process();
string sData;
oProcess.StartInfo.FileName = "cdrao.exe";
oProcess.StartInfo.Arguments = "-whatever";
oProcess.StartInfo.RedirectStandardOutput = true;
oProcess.StartInfo.CreateNoWindow = true;
oProcess.StartInfo.UseShellExecute = false;
oProcess.Start();
while (some condition)
{
sData = oProcess.StandardOutput.ReadToEnd();
.
.
}
I'm not sure about sending keystrokes. I know the SendKeys class will send keystrokes, but I believe it only sends them to the current app.
Hope this helps.
|
|
|
|