One other note. As a general rule I try to find a way to do what I want using built-in features. I figure that it's going to be faster then writing the code in RB. :-)

On Feb 9, 2007, at 9:18 AM, [EMAIL PROTECTED] wrote:

On Feb 09, 2007, at 17:02 UTC, Chris Griffin wrote:

Ouch! Kinda defeats the whole dictionaries are fast thing. I guess I
need to look and see if it would be better to just keep these things
in arrays in the first place. :-(

That may well be the case, if order matters -- an assumption of
Dictionaries is that order doesn't matter.

However, there's nothing magic about the Keys function (nor the Values
function for that matter).  It just loops through the dictionary and
gathers them up.  You can do the same thing yourself almost as fast.  I
have a StringKeys extension method I sometimes use:

Function StringKeys(Extends dict As Dictionary) As String()
  Dim i, maxi As Integer
  maxi = dict.Count - 1
  Dim out() As String
  redim out( maxi )
  for i = 0 to maxi
    out(i) = dict.Key( i )
  next
  return out
End Function

With that, your function as originally written would work (just use
StringKeys instead of .Keys).  However, you're still converting your
dictionary into a pair of arrays; if speed matters, consider just
keeping them as arrays instead.

Best,
- Joe


--
Joe Strout -- [EMAIL PROTECTED]
Verified Express, LLC     "Making the Internet a Better Place"
http://www.verex.com/

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to