Questions tagged [tdictionary]

38 questions
2
votes
3 answers

Equals and GetHashCode for TDictionary

If I implement a relationship Car <-> Owner in Delphi using a TDictionary, how should I implement the Equals and GetHashCode function of the IEqualityComparer? (GetHashCode returns an Integer which is used for hashing in TDictionary.) For the…
mjn
  • 36,362
  • 28
  • 176
  • 378
2
votes
1 answer

Default IEqualityComparer for TDictionary?

I just read "Any class that implements the IEqualityComparer interface is expected to provide the implementation for the Equals method." - (Delphi DocWiki) and "Any class that implements the IEqualityComparer interface is expected to…
mjn
  • 36,362
  • 28
  • 176
  • 378
2
votes
1 answer

Delphi Dictionary Save/Load. TDictionary not serializable?

TDictionary : SaveToFile / LoadFromFile What an elegant solution! To begin with, everything runs as expected. The content is saved to a file in a JSON format that looks right. But after reloading the file, there is a problem: Type …
user8944040
2
votes
1 answer

Delphi - Confused about memory allocation in TDictionary

In Delphi XE6, I have a TDictionary called WordDict which holds instances of TWordRec. Definitions are: WordDict: TDictionary; ... type TWordRec = class public RemoveAlways: Boolean; // Is this CORP LLC, etc? …
user1009073
  • 3,160
  • 7
  • 40
  • 82
2
votes
1 answer

GetItem on TDictionary eleminated by linker

I am using a TDictionary of . But for some reason, the linker decides that I do not want to get items out of it. I have the following code: function TSheet.GetFieldName(Field: string; Default: string): string; begin Result :=…
Svip
  • 2,958
  • 3
  • 22
  • 33
1
vote
0 answers

TDictionary equivalent that can store a few values

I can't use 'TDictionary' as I need a few Values to tag to every Key, instead of 1 value to 1 key. Example key=1, value1=label1, value2=button3 Example key=2, value1=label5, value2=button7 Will a memory table be best? What is the best TField to use…
Peter Jones
  • 451
  • 2
  • 12
1
vote
2 answers

Index (type) for searching (large) unsorted array

I have program that loads a (sometimes) large CSV file into an array. The data cannot be sorted, and I do not know if the data is text or numbers. This is up to customers. Example could be 1;JOHN;DOE 2;JANE;DOE; 3;BOBBY;NOTABLES but it could also…
MyICQ
  • 987
  • 1
  • 9
  • 25
1
vote
3 answers

TDictionary - invalid key

I have code like this: type TMyDictionary = TDictionary; var myDict: TMyDictionary; k, v: integer; // code to fill the dictionary for k in myDict.Keys do begin v := myDict.Items[k]; // other stuff end; Randomly…
TheArtTrooper
  • 1,105
  • 8
  • 19
1
vote
1 answer

delphi scope of variables question

i fill a tdictionary , read from a file, to iterate over the key-value-pairs. iterating was solved in delphi dictionary iterating. the problem is that the values in the dict are not kept, probably a scope-problem with variables. i am more used to…
soulbrother
  • 57
  • 2
  • 2
  • 7
1
vote
1 answer

delphi dictionary iterating

g'morning! i fill a dictionary TDictionary (delphi-collections-unit) with strings as values and several strings as values. something like: names = john, lisa, stan skills = read, write, speak ages = 12, 14, 16 (without "," of…
soulbrother
  • 57
  • 2
  • 2
  • 7
1
vote
3 answers

What type of collection should I use? delphi

I want to use one keys for two values in Delphi some thing like this TDictionary;
1
vote
1 answer

In a Delphi TDictionary, my Value objects are inserting as null

I'm using Delphi 9's TDictionary generic class. My TDictionary looks like this: g_FileHandlers : TDictionary>; And, so I initialize the TDictionary like so: g_FileHandlers := TDictionary>.Create; I have…
Ryan
  • 7,733
  • 10
  • 61
  • 106
1
vote
1 answer

TDictionary duplicate entry (Delphi)

I am trying to add following values to procedure TForm1.FormCreate(Sender: TObject); var md: TDictionary; s, v: string; begin md := TDictionary.Create; try s := 'orange'; v := 'fruit'; md.Add(s,…
blacksun
  • 733
  • 7
  • 24
0
votes
0 answers

Delphi 11, tDictionary containing tObjects

I have a tDictionary of variant items, I can add anything I wish, including objects. My app has a "render" function that iterates through the dictionary and converts whatever it finds into string and finally displays them all as a single document. I…
thrutch
  • 13
  • 6
0
votes
1 answer

Is it possible in Delphi to declare a TDictionary with a Generic value type?

Can Delphi make the following statement? TDictionary > The compiler doesn't like it: Undeclared identifier: 'T' I have added in the uses clause: System.Generics.Collections; UPDATE: With this code I have these…
jmontegrosso
  • 89
  • 1
  • 11