-
Need fast code..
[Originally posted by TeeGee]
I'v been programming in VB for seven days now and came to a problem. I need to find a better function for permutating. it's called with elements in range 2-10 and run the testp(blah) function for every permutation.. you got a faster
idea??
Public Function permc(ByRef elements As Byte, perms() As Byte)
ÿ ÿ
ÿ ÿ If elements = 2 Then
ÿ ÿ ÿ ÿ ÿ ÿ Call testp(perms())
ÿ ÿ ÿ ÿ table(0) = table(1) 'index 0 is just
ÿ ÿ ÿ ÿ table(1) = table(2) 'for swiching
ÿ ÿ ÿ ÿ table(2) = table(0) 'elements
ÿ ÿ ÿ ÿ ÿ ÿ Call testp(perms())
ÿ ÿ ÿ ÿ table(0) = table(1)
ÿ ÿ ÿ ÿ table(1) = table(2)
ÿ ÿ ÿ ÿ table(2) = table(0)
ÿ ÿ Else
ÿ ÿ ÿ ÿ For Counter = 1 To elements
ÿ ÿ ÿ ÿ ÿ ÿ table(0) = perms(elements)
ÿ ÿ ÿ ÿ ÿ ÿ table(elements) = table(Counter)
ÿ ÿ ÿ ÿ ÿ ÿ table(Counter) = table(0)
ÿ ÿ ÿ ÿ ÿ ÿ ÿ ÿ Call permc(elements - 1,perms())
ÿ ÿ ÿ ÿ ÿ ÿ table(0) = table(elements)
ÿ ÿ ÿ ÿ ÿ ÿ table(elements) = table(Counter)
ÿ ÿ ÿ ÿ ÿ ÿ table(Counter) = table(0)
ÿ ÿ ÿ ÿ Next
ÿ ÿ End If
end function
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks