Re: map/multimap/wildcards




"Jason S" <jmsachs@xxxxxxxxx> a écrit dans le message de news:
1149790993.418819.325110@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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. I am *NOT* going to expand this to
regexp searches (which I have no idea how to implement efficiently).

This seems to cry out for a multimap, I think...

No, multimap won't help you there : the only difference between a map and a
multimap is that the multimap allow several objects witht the same key,
which the map forbids. However, the multimap manages oonly when comparison
object and one sorting of elements.

What you are after is either lower_bound that was proposed by other, either,
if you want a more generic solution, a multi-index container. Boost provides
such a beast : see http://www.boost.org/libs/multi_index/doc/index.html

Arnaud
MVP - VC


.



Relevant Pages

  • map/multimap/wildcards
    ... character string lookup in sorted order. ... Works great for exact matches. ... The "dumb" method is to walk through the entire map, ...
    (microsoft.public.vc.stl)
  • Re: multimap help
    ... > I was wondering if anyone new or had example code that uses a multimap (or ... > just a map). ... each character value in a string: ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Oracle Connection Pooling
    ... > public String oracleFormatUrl(String prefix, String host, String port, ... > proprietaryException { ... > * Map from a resource attribute to a proprietary attribute. ... > protected void processCreateRequests ...
    (comp.lang.java.databases)
  • [UML] Collections
    ... ich arbeite sehr gern mit Java-Collections, ... In gewisser Weise ähnelt eine MultiMap ... dass es in der Entity-Relationship-Modellierung ... Wenn man eine Map in eine bidirektionale Map ...
    (de.comp.lang.java)
  • Re: Irregular review procedures for IACR sponsored conferences
    ... There are only three theorems. ... The second says that if you apply the map to an arbitrary but sufficiently ... long string, substrings of the image are uniformly distributed. ... the policy might look pretty dubious. ...
    (sci.crypt)