Questions tagged [tdictionary]

38 questions
24
votes
1 answer

Delphi TDictionary iteration

I have a function where I store some key- value pairs and when I iterate them I get this error twice: [dcc32 Error] App.pas(137): E2149 Class does not have a default property. Here is part of my code: function BuildString: string; var i: Integer; …
bob_saginowski
  • 1,429
  • 2
  • 20
  • 35
19
votes
3 answers

How Can I List a TDictionary in Alphabetical Order by Key in Delphi 2009?

How can I use a TEnumerator to go through my TDictionary in sorted order by key? I've got something like this: var Dic: TDictionary; Enum: TPair; begin Dic := TDictionary.create; …
lkessler
  • 19,819
  • 36
  • 132
  • 203
16
votes
4 answers

Is there an easy way to copy the TDictionary content into another?

Is there a single method or easy way how to copy one TDictionary content into another ? Let's say I have the following declarations type TItemKey = record ItemID: Integer; ItemType: Integer; end; TItemData = record Name: string; …
Martin Reiner
  • 2,167
  • 2
  • 20
  • 34
14
votes
3 answers

delphi Using records as key in TDictionary

Can you use a record as a Key value in TDictionary? I want to find objects based on combination of string, integer and integer. TUserParKey=record App:string; ID:integer; Nr:integer; end; ... var tmpKey:TUserParKey; …
r_j
  • 1,348
  • 15
  • 35
9
votes
2 answers

How to create a custom enumerator for a class derived from TDictionary?

I have defined a collection derived from TDictionary, and need to define a custom enumerator that apply an additional filter. I'm stuck as I can't access the TDictionary FItems array (it is private) so I can't define the MoveNext method How would…
user315561
  • 651
  • 5
  • 18
9
votes
1 answer

Sorting TDictionary by a key of Integer in ascending order

How can I sort TDictionary by a key of Integer in ascending order in Delphi 2009?
Max Smith
  • 395
  • 1
  • 2
  • 13
7
votes
1 answer

Why does a deserialized TDictionary not work correctly?

I try serialize/deserialize standard delphi container using standard delphi serializer. procedure TForm7.TestButtonClick(Sender: TObject); var dict: TDictionary; jsonValue: TJSONValue; begin //serialization dict :=…
aQuu
  • 565
  • 8
  • 18
7
votes
1 answer

How to get the key from a TDictionary?

I have a TDictionary. I want to accomplish something like for i := 0 to MyDictionary.Count -1 do ShowMessage(MyDictionary.Keys[i].AStringProperty) I cannot Access the Keys anymore I can just use them if I exactly know…
UnDiUdin
  • 14,924
  • 39
  • 151
  • 249
7
votes
1 answer

Class field (static field) in Delphi

There is a class TPerson. It is known that FSecondName unique to each object. type TPerson = class(TObject) private FAge: Integer; FFirstName: String; FSecondName: String; public property Age: Integer read FAge; …
Andrew
  • 157
  • 2
  • 7
6
votes
1 answer

GetHashCode good practice?

For a Delphi project (built with RAD Studio XE7), I want to create a dictionary of brushes. Each dictionary item contains a TMyBrush object as key, that describes the brush to retrieve, and a GDI+ brush as value. The TMyBrush class contains 3…
Jean-Milost Reymond
  • 1,833
  • 1
  • 15
  • 36
5
votes
1 answer

Delphi dictionary freeing

I implemented the following class: type TUtilProcedure = procedure(var AJsonValue: TJSONObject); TCallback = class private FName: string; FProcedure: TUtilProcedure; FAnnotation: string; public constructor Create(AName:…
bob_saginowski
  • 1,429
  • 2
  • 20
  • 35
5
votes
2 answers

Create a constant array of TDictionary by default value

I want to use the a TDictionary in a Delphi project. But I've a problem,how i can Create a constant array of TDictionary by default value ? For example i want to allocate 4 item for a dictionary such as bellow code (for constant array of TItem) …
Behrooz
  • 684
  • 1
  • 9
  • 19
5
votes
1 answer

Correct way to dispose of TDictionary after sorting it into an array

I have a TDictionary like target_results : TDictionary; After populating it I need to sort the results. I'm doing it like this type TSearchResult = TPair; var target_results_array :…
Miguel E
  • 1,316
  • 2
  • 17
  • 39
4
votes
1 answer

TDictionary save to file

I have a lot of files(about 160 000) and I need to have information about position of individual words in files(fulltext). So I used Dictionary like this: WordDict : TDictionary>; Now I know that WORD1…
user1990191
  • 43
  • 1
  • 4
2
votes
0 answers

Serialize Delphi TDictionary to JSON string as C#

I have a Delphi program written in Alexandria 11.1 that needs to send a JSON file to a service that is written in C#. If the JSON structure is static, I create a model class and use the native TJson.ObjectToJsonString of REST.Json to convert it to…
stmpakir
  • 319
  • 2
  • 10
1
2 3