Re: map/multimap/wildcards

Tech-Archive recommends: Speed Up your PC by fixing your registry



Jason S <jmsachs@xxxxxxxxx> wrote:
Argh. I keep an index (presently implemented as map<char *, long,
pchar_cmp> where pchar_cmp calls strcmp() appropriately; the "char *"s
are stored elsewhere & will exist as long as the map does) for
character string lookup in sorted order. Works great for exact
matches. Now I need an alternate accessor (need to keep the
exact-match lookup around) to use it for string completion, e.g. find
all the entries that start with an arbitrary string.

Use lower_bound to find the first string that starts with the prefix (if
any). Walk from this point on until you find the first string that does
not start with the prefix.

Alternatively, call lower_bound with the prefix, and upper_bound with
prefix+'\0xFF' (that is a string consisting of your prefix and an extra
character '\0xFF' at the end). This will give you the range.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


.



Relevant Pages

  • bugs in .NETCF SP2
    ... XmlDocument.CreateNode(XmlNodeType, String, String) specifying a ... namespace as third parameter creating an element node will set the ... automatically a prefix in the XmlNode.OuterXml property. ... OuterXml property just uses the localname without prefix. ...
    (microsoft.public.dotnet.framework.compactframework)
  • bugs in .NET compact framework
    ... XmlDocument.CreateNode(XmlNodeType, String, String) specifying a ... namespace as third parameter creating an element node will set the ... automatically a prefix in the XmlNode.OuterXml property. ... OuterXml property just uses the localname without prefix. ...
    (microsoft.public.pocketpc.developer)
  • Re: treeView key change tracking
    ... I think this is why I can not figure out how to capture the prefix that has been assigned at any particular level. ... (becuase it is a recursive recordset, I can not assign levels ie. acct, master, invoice) ... nodParent) for a part that has children, ... Sub AddBranch(rs As Recordset, strPointerField As String, _ ...
    (microsoft.public.access.modulesdaovba)
  • Re: Macro for Changing Files Names
    ... The code for a folder browser is at ... Dim OldName As String, NewName As String ... Dim Prefix As String ...
    (microsoft.public.word.vba.general)
  • Re: [OT]Another n00b: Removing the space in "print text, var"
    ... Instead, the prefix was to indicate the function of the variable, not its datatype. ... indicator of a string class, ... what is this 'str' prefix supposed to mean? ... In a dynamic language, that variance could easily happen, which appears to be the basis for your "even *more* evil" comment. ...
    (comp.lang.python)