<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns="http://www.w3.org/TR/REC-html40" xmlns:v =
"urn:schemas-microsoft-com:vml" xmlns:o =
"urn:schemas-microsoft-com:office:office" xmlns:w =
"urn:schemas-microsoft-com:office:word" xmlns:st1 =
"urn:schemas-microsoft-com:office:smarttags"><HEAD><TITLE>Message</TITLE>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2800.1226" name=GENERATOR><!--[if !mso]>
<STYLE>v\:* {
        BEHAVIOR: url(#default#VML)
}
o\:* {
        BEHAVIOR: url(#default#VML)
}
w\:* {
        BEHAVIOR: url(#default#VML)
}
.shape {
        BEHAVIOR: url(#default#VML)
}
</STYLE>
<![endif]--><o:SmartTagType name="country-region"
namespaceuri="urn:schemas-microsoft-com:office:smarttags"></o:SmartTagType><o:SmartTagType
name="place"
namespaceuri="urn:schemas-microsoft-com:office:smarttags"></o:SmartTagType><o:SmartTagType
name="PersonName"
namespaceuri="urn:schemas-microsoft-com:office:smarttags"></o:SmartTagType><!--[if !mso]>
<STYLE>st1\:* {
        BEHAVIOR: url(#default#ieooui)
}
</STYLE>
<![endif]-->
<STYLE>@font-face {
        font-family: Wingdings;
}
@font-face {
        font-family: Tahoma;
}
@page Section1 {size: 595.3pt 841.9pt; margin: 72.0pt 90.0pt 72.0pt 90.0pt; }
P.MsoNormal {
        FONT-SIZE: 12pt; MARGIN: 0cm 0cm 0pt; COLOR: black; FONT-FAMILY: "Times New Roman"
}
LI.MsoNormal {
        FONT-SIZE: 12pt; MARGIN: 0cm 0cm 0pt; COLOR: black; FONT-FAMILY: "Times New Roman"
}
DIV.MsoNormal {
        FONT-SIZE: 12pt; MARGIN: 0cm 0cm 0pt; COLOR: black; FONT-FAMILY: "Times New Roman"
}
A:link {
        COLOR: blue; TEXT-DECORATION: underline
}
SPAN.MsoHyperlink {
        COLOR: blue; TEXT-DECORATION: underline
}
A:visited {
        COLOR: blue; TEXT-DECORATION: underline
}
SPAN.MsoHyperlinkFollowed {
        COLOR: blue; TEXT-DECORATION: underline
}
PRE {
        FONT-SIZE: 10pt; MARGIN: 0cm 0cm 0pt; COLOR: black; FONT-FAMILY: "Courier New"
}
SPAN.EmailStyle18 {
        COLOR: navy; FONT-FAMILY: Arial; mso-style-type: personal-reply
}
DIV.Section1 {
        page: Section1
}
</STYLE>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></HEAD>
<BODY lang=EN-GB vLink=blue link=blue bgColor=white>
<DIV><SPAN class=887303421-07102004><FONT face=Arial color=#0000ff
size=2>Easiest way is to use a sorted TStringlist by binary
search.</FONT></SPAN></DIV>
<DIV><SPAN class=887303421-07102004><FONT face=Arial color=#0000ff
size=2>Advance way is to use ternary search tree. 8 )</FONT></SPAN></DIV>
<DIV><SPAN class=887303421-07102004><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=887303421-07102004><FONT face=Arial color=#0000ff
size=2>Regards</FONT></SPAN></DIV>
<DIV><SPAN class=887303421-07102004><FONT face=Arial color=#0000ff
size=2>Leigh</FONT></SPAN></DIV>
<DIV><SPAN class=887303421-07102004><FONT face=Arial color=#0000ff
size=2>Cameraman</FONT></SPAN></DIV>
<DIV><SPAN class=887303421-07102004><FONT face=Arial color=#0000ff size=2><A
href="http://www.salenz.com">http://www.salenz.com</A></FONT></SPAN></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma
size=2>-----Original Message-----<BR><B>From:</B> delphi-bounces@ns3.123.co.nz
[mailto:delphi-bounces@ns3.123.co.nz]<B>On Behalf Of </B>Stephen
Bertram<BR><B>Sent:</B> Friday, October 08, 2004 10:13 AM<BR><B>To:</B> NZ
Borland Developers Group - Delphi List<BR><B>Subject:</B> RE: [DUG] there has
to be a better way to do this....<BR><BR></FONT></DIV>
<DIV class=Section1>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">You are right in this
case Kyley as the data is static – I can’t see major changes to the ISD codes
every 10 minutes </SPAN></FONT><FONT face=Wingdings color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Wingdings">J</SPAN></FONT><FONT
face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">.<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">But in general, where
you are searching against a changing database, it is preferable to run the
query aganst the live data provided that you are dealing with a manageable
number of simultaneous users (< 1000).<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">$0.02<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">Stephen<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></P>
<DIV>
<DIV class=MsoNormal style="TEXT-ALIGN: center" align=center><FONT
face="Times New Roman" color=black size=3><SPAN lang=EN-US
style="FONT-SIZE: 12pt; COLOR: windowtext">
<HR tabIndex=-1 align=center width="100%" SIZE=2>
</SPAN></FONT></DIV>
<P class=MsoNormal><B><FONT face=Tahoma color=black size=2><SPAN lang=EN-US
style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: windowtext; FONT-FAMILY: Tahoma">From:</SPAN></FONT></B><FONT
face=Tahoma color=black size=2><SPAN lang=EN-US
style="FONT-SIZE: 10pt; COLOR: windowtext; FONT-FAMILY: Tahoma">
delphi-bounces@ns3.123.co.nz [mailto:delphi-bounces@ns3.123.co.nz] <B><SPAN
style="FONT-WEIGHT: bold">On Behalf Of </SPAN></B>Kyley Harris<BR><B><SPAN
style="FONT-WEIGHT: bold">Sent:</SPAN></B> Friday, 8 October 2004 9:51
a.m.<BR><B><SPAN style="FONT-WEIGHT: bold">To:</SPAN></B> vss@vss.co.nz;
<st1:PersonName w:st="on">NZ Borland Developers Group - Delphi
List</st1:PersonName><BR><B><SPAN
style="FONT-WEIGHT: bold">Subject:</SPAN></B> Re: [DUG] there has to be a
better way to do this....</SPAN></FONT><FONT color=black><SPAN lang=EN-US
style="COLOR: windowtext"><o:p></o:p></SPAN></FONT></P></DIV>
<P class=MsoNormal><FONT face="Times New Roman" color=black size=3><SPAN
style="FONT-SIZE: 12pt"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" color=black size=3><SPAN
style="FONT-SIZE: 12pt">how obscene is 1500 records in memory? on a 3ghz
machine with 1gb of ram thats like wondering if your wallet will miss 5
cents.<BR><BR>I'll happily cache 100000 records in memory, as long as its
updated properly, and do my seeks un 300ms on that kind of search. RAM is no
magical wonderbeing. the purpose of increasing ram is so that you can use it
for such things,<BR><BR>Jeremy Coulter wrote: <o:p></o:p></SPAN></FONT></P>
<DIV>
<P class=MsoNormal><FONT face=Arial color=black size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">HI
All.</SPAN></FONT><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><FONT face="Times New Roman" color=black size=3><SPAN
style="FONT-SIZE: 12pt"> <o:p></o:p></SPAN></FONT></P></DIV>
<DIV>
<P class=MsoNormal><FONT face=Arial color=black size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">We have a database that stores
phone numbers but Country Code and location
code.</SPAN></FONT><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><FONT face="Times New Roman" color=black size=3><SPAN
style="FONT-SIZE: 12pt"> <o:p></o:p></SPAN></FONT></P></DIV>
<DIV>
<P class=MsoNormal><FONT face=Arial color=black size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">i.e. 0061 - <st1:country-region
w:st="on"><st1:place w:st="on">australia</st1:place></st1:country-region>,
786 - gold coast</SPAN></FONT><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><FONT face="Times New Roman" color=black size=3><SPAN
style="FONT-SIZE: 12pt"> <o:p></o:p></SPAN></FONT></P></DIV>
<DIV>
<P class=MsoNormal><FONT face=Arial color=black size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">We pass a number to a function,
and this function finds where the number is
for.</SPAN></FONT><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><FONT face="Times New Roman" color=black size=3><SPAN
style="FONT-SIZE: 12pt"> <o:p></o:p></SPAN></FONT></P></DIV>
<DIV>
<P class=MsoNormal><FONT face=Arial color=black size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">The location code has a max length
of 9 numbers, and so what I do is currently loop FOR x:=9 downto 1, and
it querys the DB i.e. select * from the_table where location =
copy(number,1,x)</SPAN></FONT><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><FONT face=Arial color=black size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">BUT I REALLY thik this is
bad...whilst it works, its not prob. the best thing to do....i.e. potentually
9 querys to a db.</SPAN></FONT><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><FONT face="Times New Roman" color=black size=3><SPAN
style="FONT-SIZE: 12pt"> <o:p></o:p></SPAN></FONT></P></DIV>
<DIV>
<P class=MsoNormal><FONT face=Arial color=black size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">There HAS to be a better way to do
this !</SPAN></FONT><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><FONT face=Arial color=black size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">I did think maybe of storing the
data into a collection and itterating thru the collection which would be a
HELL of a lot faster than going to the DB, but how obscene would it be to
store over 1500 records into memory?</SPAN></FONT><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><FONT face="Times New Roman" color=black size=3><SPAN
style="FONT-SIZE: 12pt"> <o:p></o:p></SPAN></FONT></P></DIV>
<DIV>
<P class=MsoNormal><FONT face=Arial color=black size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">I thought there might be away to
do it even in an SQL statement, but I cant think of how to structure
it....this is an Access DB too, although after xmas it will be MS SQL Server
(and MSDE).</SPAN></FONT><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><FONT face="Times New Roman" color=black size=3><SPAN
style="FONT-SIZE: 12pt"> <o:p></o:p></SPAN></FONT></P></DIV>
<DIV>
<P class=MsoNormal><FONT face=Arial color=black size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">If anyone has some thoughts, let
me know.....this should get the list going again
:-D</SPAN></FONT><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><FONT face="Times New Roman" color=black size=3><SPAN
style="FONT-SIZE: 12pt"> <o:p></o:p></SPAN></FONT></P></DIV>
<DIV>
<P class=MsoNormal><FONT face=Arial color=black size=2><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Jeremy</SPAN></FONT><o:p></o:p></P></DIV><PRE wrap=""><FONT face="Courier New" color=black size=2><SPAN style="FONT-SIZE: 10pt"><o:p> </o:p></SPAN></FONT></PRE><PRE style="TEXT-ALIGN: center"><FONT face="Courier New" color=black size=2><SPAN style="FONT-SIZE: 10pt">
<HR align=center width="90%" SIZE=4>
</SPAN></FONT></PRE><PRE><FONT face="Courier New" color=black size=2><SPAN style="FONT-SIZE: 10pt"><o:p> </o:p></SPAN></FONT></PRE><PRE><FONT face="Courier New" color=black size=2><SPAN style="FONT-SIZE: 10pt">_______________________________________________<o:p></o:p></SPAN></FONT></PRE><PRE><st1:place w:st="on"><FONT face="Courier New" color=black size=2><SPAN style="FONT-SIZE: 10pt">Delphi</SPAN></FONT></st1:place> mailing list<o:p></o:p></PRE><PRE><FONT face="Courier New" color=black size=2><SPAN style="FONT-SIZE: 10pt"><A href="mailto:Delphi@ns3.123.co.nz">Delphi@ns3.123.co.nz</A><o:p></o:p></SPAN></FONT></PRE><PRE><FONT face="Courier New" color=black size=2><SPAN style="FONT-SIZE: 10pt"><A href="http://ns3.123.co.nz/mailman/listinfo/delphi">http://ns3.123.co.nz/mailman/listinfo/delphi</A><o:p></o:p></SPAN></FONT></PRE><PRE><FONT face="Courier New" color=black size=2><SPAN style="FONT-SIZE: 10pt"> <o:p></o:p></SPAN></FONT></PRE></DIV>
<DIV>
<P><FONT
size=2>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<BR>This communication contains information that is confidential and the
copyright of ensynergy Limited or a third party. <BR><BR>If you are not the
intended recipient of this communication please delete and destroy all copies
and telephone ensynergy Limited on +64 9 3551591 immediately. If you are the
intended recipient of this communication you should not copy, disclose or
distribute this communication without the authority of ensynergy Limited.
<BR><BR>Any views expressed in this communication are those of the individual
sender, except where the sender specifically states them to be the views of
ensynergy Limited. <BR><BR>Except as required by law, ensynergy Limited does
not represent, warrant and/or guarantee that the integrity of this
communication has been maintained nor that the communication is free of
errors, virus, interception or interference.
<BR></FONT></P></DIV></BLOCKQUOTE></BODY></HTML>