- edited description
Possible issue with IBiDiDictionary and default enumerator.
Issue #353
resolved
It seems that the default enumerator for IBiDiDictionary returns the inverse enumerator. Or at least the following code shows values as keys and keys as values. The following console program returns:
Actual results:
// These seem reversed
Key: Val1 Value: Key1
Key: Val2 Value: Key2
Key: Val3 Value: Key3
// These seem correct for Inverse.
Inverse Keys and Values
Key: Val1 Value: Key1
Key: Val2 Value: Key2
Key: Val3 Value: Key3
Expected Results:
Key: Key1 Value: Val1
Key: Key2 Value: Val2
Key: Key3 Value: Val3
Inverse Keys and Values
Key: Val1 Value: Key1
Key: Val2 Value: Key2
Key: Val3 Value: Key3
Thanks! Let me know if I’ve misunderstood something.
program BiDiDictIssue;
{$APPTYPE CONSOLE}
{$R *.res}
uses
WinApi.Windows,
System.Classes,
System.SysUtils,
Spring.Collections;
var
MyList: IBidiDictionary<String, String>;
p: TPair<String, String>;
begin
Writeln('');
Writeln('IBidiDictionary Test');
Writeln('');
MyList := TCollections.CreateBidiDictionary<String, String>(TStringComparer.OrdinalIgnoreCase, TStringComparer.OrdinalIgnoreCase);
MyList['Key1'] := 'Val1';
MyList['Key2'] := 'Val2';
MyList['Key3'] := 'Val3';
Writeln('Keys and Values');
for p in MyList do
Writeln(' Key: ', p.Key, ' Value: ', p.Value);
Writeln('Inverse Keys and Values');
for p in MyList.Inverse do
Writeln(' Key: ', p.Key, ' Value: ', p.Value);
Writeln('');
Write('Press Enter to quit...');
ReadLn;
end.
Comments (2)
-
reporter -
repo owner - changed status to resolved
fixed
#353→ <<cset 70c36b52c6f6>>
- Log in to comment