<p style="padding:0 0 0 0; margin:0 0 0 0;">I looked to code, it gives error only when map is Sorted=True.</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">function TFPSMap.Add(AKey: Pointer): Integer;</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">begin</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> if Sorted then</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> begin</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> if Find(AKey, Result) then</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> case Duplicates of</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> dupIgnore: exit;</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> dupError: Error(SDuplicateItem, 0)</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> end;</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> end else</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> Result := Count;</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> CopyKey(AKey, inherited Insert(Result));</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">end; </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;"> </p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">V.</p>
<p style="padding:0 0 0 0; margin:0 0 0 0;">______________________________________________________________<br />
> Od: "Ryan Joseph via fpc-pascal" <fpc-pascal@lists.freepascal.org><br />
> Komu: "FPC-Pascal users discussions" <fpc-pascal@lists.freepascal.org><br />
> Datum: 02.10.2020 02:24<br />
> Předmět: [fpc-pascal] TFPGMapObject duplicate errors<br />
></p>
I expected to get an assertion when I added the duplicate key "foo". What am I doing wrong?<br />
<br />
type<br />
TSomeMap = specialize TFPGMapObject<String, TObject>;<br />
var<br />
map: TSomeMap;<br />
begin<br />
map := TSomeMap.Create(true);<br />
map.Duplicates := dupError;<br />
map.Add('foo', TObject.Create);<br />
map.Add('foo', TObject.Create);<br />
<br />
Regards,<br />
Ryan Joseph<br />
<br />
_______________________________________________<br />
fpc-pascal maillist - fpc-pascal@lists.freepascal.org<br />
<a href="https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal">https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal</a><br />