View Issue Details

IDProjectCategoryView StatusLast Update
0037609FPCRTLpublic2020-09-11 16:52
Reporterravi dion Assigned ToSven Barth  
PrioritynormalSeverityminorReproducibilityN/A
Status resolvedResolutionfixed 
Product Version3.3.1 
Fixed in Version3.3.1 
Summary0037609: Add TryAdd method to TDictionary
DescriptionNoticed that there is TryAdd in Rio for Generics Collections
Additional Informationhttp://docwiki.embarcadero.com/Libraries/Rio/en/System.Generics.Collections.TDictionary.TryAdd
TagsNo tags attached.
Fixed in Revision46839
FPCOldBugId
FPCTarget-
Attached Files

Activities

Marco van de Voort

2020-08-20 23:17

manager   ~0125044

Not much doc, but sounds like a part of addorsetvalue?

Something like

var
  LIndex: SizeInt;
  LHash: UInt32;
begin
  LIndex := FindBucketIndex(FItems, AKey, LHash);
 result:=lindex<0;
  if result then
    DoAdd(AKey, AValue);

ravi dion

2020-08-26 20:49

reporter   ~0125141

or

success:=true;
try
  Add(key,value);
except
  success:=false;
end;

Bart Broersma

2020-08-26 23:17

reporter   ~0125144

@ravi: exceptions are expensive.

Thaddy de Koning

2020-08-27 16:52

reporter   ~0125158

Last edited: 2020-08-27 16:55

View 2 revisions

Too expensive.. All TryXXX are written in a manner that avoid exceptions for that reason.
Marco's example is OK afaik.

ravi dion

2020-09-10 23:39

reporter   ~0125465

Can the code from Marco added to the unit?

Sven Barth

2020-09-11 16:52

manager   ~0125485

Please test and close if okay.

Issue History

Date Modified Username Field Change
2020-08-20 22:09 ravi dion New Issue
2020-08-20 23:17 Marco van de Voort Note Added: 0125044
2020-08-26 20:49 ravi dion Note Added: 0125141
2020-08-26 23:17 Bart Broersma Note Added: 0125144
2020-08-27 16:52 Thaddy de Koning Note Added: 0125158
2020-08-27 16:55 Thaddy de Koning Note Edited: 0125158 View Revisions
2020-09-10 23:39 ravi dion Note Added: 0125465
2020-09-11 16:52 Sven Barth Assigned To => Sven Barth
2020-09-11 16:52 Sven Barth Status new => resolved
2020-09-11 16:52 Sven Barth Resolution open => fixed
2020-09-11 16:52 Sven Barth Fixed in Version => 3.3.1
2020-09-11 16:52 Sven Barth Fixed in Revision => 46839
2020-09-11 16:52 Sven Barth FPCTarget => -
2020-09-11 16:52 Sven Barth Note Added: 0125485