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