Logo

Programming-Idioms

History of Idiom 13 > diff from v64 to v65

Edit summary for version 65 by Anonymous:
[Pascal] Pascal has been traditionally 1-based rather than 0-based, by convention

Version 64

2019-09-26, 18:04:58

Version 65

2019-09-26, 18:18:10

Idiom #13 Iterate over map keys and values

Print each key k with its value x from an associative array mymap

Illustration

Idiom #13 Iterate over map keys and values

Print each key k with its value x from an associative array mymap

Illustration
Extra Keywords
table dictionary hash traverse traversal
Extra Keywords
table dictionary hash traverse traversal
Imports
uses fgl;
type TMyMap = specialize TFPGMap<String, Integer>;
Imports
uses fgl;
type TMyMap = specialize TFPGMap<String, Integer>;
Code
for i := 0 to mymap.Count - 1 do
  WriteLn(mymap.Keys[i], '=', mymap.Data[i]);
Code
for i := 1 to mymap.Count 		do
  WriteLn(mymap.Keys[i], '=', mymap.Data[i]);
Doc URL
http://wiki.freepascal.org/Generics#fgl_unit
Doc URL
http://wiki.freepascal.org/Generics#fgl_unit