hmmm... it is very similar. the only thing is, mine reduces the section of the array scanned by far more than the wiki examples do per itteration of the outer loop. i had no idea that it was basicly the same as some other seemingly common enough piece of code, oh well. i guess thats as good as it gets then. i'm pretty sure if i used one of the examples it'd take the same number of loops of the outer loop but the majority of the loops would take longer with the wiki code to complete the sorting. thanks anyway guys.[:^)]
paenis
@paenis
Best posts made by paenis
Latest posts made by paenis
-
RE: Vbscript ported to vb.net, any chance of better code?
-
RE: Vbscript ported to vb.net, any chance of better code?
well sure, i can change it now. but you guys gotta remember, in vbscript, length of everything hits performance. the original had no formatting and every possible space was removed for performance. anyhow, i know if i was doing in it C/C++ i'd probably be swapping pointers instead of the data in the arrays, but then again i dont like C/C++. just my preference. anyhow, i'm pretty new to VB.net and still dont even know if thats possible to do so if anybody can tell me otherwise that'd be great, but seeing as how you guys are more conscerned with the variable names than answering my request i'm guessing the answer is no. come on guys, you can do better [:P]
-
RE: C# and SQL problem
i dont know man.i dont do this sort of thing myself but it seems to me you're going to have to use voodoo. if it were me however, i'd connect to each database one at a time and cache the data locally.then once everything is gathered up, cast magic missile. i suppose the best thing would be to code whatever it is you're trying to do from scratch and apply it to the data, or the data to it, whatever. i'm lost already. or you could just do a wtf, copy the table from one server to a temp table on the other, do your thing, then delete the temp table after you have your result. aside from that, i cant really think of anything else since i'm not entirely certain of what it is you're attempting to do because i just woke up and probably wont be able to think straight for another hour or two.
so um... disreguard that, i'm gonna go find some socks.[{]
-
Vbscript ported to vb.net, any chance of better code?
well it finally happened, i've been charged with porting an old vbscript "application" to VB.net. part of what this mess had to do was deal with some massive arrays of about 30,000 elements. i made a set of functions to sort the data of the arrays and keep them relative to eachother. in all theres about a half dozen of these and the original code ran suprisingly fast in vbscript, given the scope of the task and it being written in vbscript of all things. anyhow, whats done is done and for the sake of my own sanity i changed the original function names all to xsort with overloading because i just know once i'm done they're gonna have me do something else to the program. [:'(] but anyhow here it is, ported to VB.net, this sample rearranges the data in 2 arrays based on the first. somebody tell me there's a faster way to sort a set of arrays side-by-side in excess of 30k elements. commenting added for clarity. bear in mind that vbscript is fairly limited in it's collection of functions/methods/etc and this was originally coded for that back in the days of win98.
Public Overloads Function xsort(ByRef p As String(), ByRef d As String()) As Boolean
On Error GoTo errorline
Dim n As Long = UBound(p, 1)
Dim y As Long = 0
Dim s As Long = n - 1
Dim a As Long = 0
Dim b As Long = 0
Dim q As Byte = 0
Dim t As Long = 0
Dim x As String = "" 'innitialize to empty
For a = 0 To n - 1 'theoretical maximum possible number of passes required to sort
q = 1 'this variable tests that a swap was made in this pass
For b = y To (s) 'ascending pass, carries the highest value all the way to the highest element
If (StrComp(p(b), p(b + 1), CompareMethod.Binary) > 0) Then
x = p(b)
p(b) = p(b + 1)
p(b + 1) = x
x = d(b)
d(b) = d(b + 1)
d(b + 1) = x
q = 0 'a swap was made
s = b 'highest point of swap, everything after this point doesnt need checking
End If
Next
For t = n - s To n - y 'descending pass, carries lowest value all the way to the lowest element
b = n - t
If (StrComp(p(b), p(b + 1), CompareMethod.Binary) > 0) Then
x = p(b)
p(b) = p(b + 1)
p(b + 1) = x
x = d(b)
d(b) = d(b + 1)
d(b + 1) = x
q = 0 'a swap was made
y = b 'lowest point of swap, everything before blah blah
End If
Next
If (q = 1) Then 'if q is still 1 then no swaps were made forewards or back in this itteration. sorting is complete.
Return True
Exit Function
End If
Next
Return True
Exit Function
errorline:
Console.WriteLine("error code: {0} ", Err.Number)
Return False
Exit Function
End Functioni just hope this doesnt end up being a new wtf.
-
RE: Best error message ever
well just think of it this way, atleast wrong error handling is better than no error handling.