Q
QDL
Hello everyone,
I have a very simple question about arrays I have an array of Processes
objects (retrieved using Process.GetProcesses()). I want to sort them
descending on the WorkingSet size.
Is this code correct?
Dim temp as Process
Dim mProcessi() as Process
Dim i, j, n as Integer
n = mProcessi.GetUpperBound(0)
For i = 0 To n - 1
For j = i + 1 To n
If mProcessi(i).WorkingSet < mProcessi(j).WorkingSet Then
temp = mProcessi(i)
mProcessi(i) = mProcessi(j)
mProcessi(j) = temp
End If
Next
Next
I think it is all right. Temp is just a pointer to an instance of Process as
all elements in mProcessi array are, so doing so I just sort the pointers to
the objects and I should not mess with memory, resources and so on...
TIA
Paolo
I have a very simple question about arrays I have an array of Processes
objects (retrieved using Process.GetProcesses()). I want to sort them
descending on the WorkingSet size.
Is this code correct?
Dim temp as Process
Dim mProcessi() as Process
Dim i, j, n as Integer
n = mProcessi.GetUpperBound(0)
For i = 0 To n - 1
For j = i + 1 To n
If mProcessi(i).WorkingSet < mProcessi(j).WorkingSet Then
temp = mProcessi(i)
mProcessi(i) = mProcessi(j)
mProcessi(j) = temp
End If
Next
Next
I think it is all right. Temp is just a pointer to an instance of Process as
all elements in mProcessi array are, so doing so I just sort the pointers to
the objects and I should not mess with memory, resources and so on...
TIA
Paolo