How to iterate properly over the search results of a DMultiMap (DeCAL) in Delphi? -


i using dmultimap container decal delphi 6 store data. key string can appears several time in map.

i wonder how iterate on objects given key.

will code:

function iterateoverobjects(map: dmultimap); var iter: diterator; begin   iter := map.locate(['abc']);   while iterateover(iter)   begin     // value...   end; end; 

returns objects of 'abc' key? or returns objects of map starting first object 'abc' key?

edit: tested. returns objects of map starting first object 'abc' key. best way iterate on 'abc'?

edit: tested version (i've changed used findif, because investigated doesn't use fast locate, loops through items):

edit2: because previous test bad, i've edited function make work properly. looks same name's answer, changed not confuse incorrect function.

    function iterateoverfound(map: dmultimap; var iter: diterator; const obj: array of const): boolean; begin   if diiteration in iter.flags   begin     advance(iter);     settokey(iter);     iter := findin(iter, map.finish, obj);   end   else   begin     iter := map.locate(obj);     include(iter.flags, diiteration);   end;    result := not atend(iter);   if not result     exclude(iter.flags, diiteration); end; 

example usage:

var   iter: diterator;    iter := map.start;    while iterateoverfound(map, iter, ['abc'])   begin     settovalue(iter);     // value   end; 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -