Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -0,0 +1,41 @@
|
|||
MODULE AssociativeArray;
|
||||
IMPORT
|
||||
ADT:Dictionary,
|
||||
Object:Boxed,
|
||||
Out;
|
||||
TYPE
|
||||
Key = STRING;
|
||||
Value = Boxed.LongInt;
|
||||
|
||||
VAR
|
||||
assocArray: Dictionary.Dictionary(Key,Value);
|
||||
iterK: Dictionary.IterKeys(Key,Value);
|
||||
iterV: Dictionary.IterValues(Key,Value);
|
||||
aux: Value;
|
||||
k: Key;
|
||||
|
||||
BEGIN
|
||||
assocArray := NEW(Dictionary.Dictionary(Key,Value));
|
||||
assocArray.Set("ten",NEW(Value,10));
|
||||
assocArray.Set("eleven",NEW(Value,11));
|
||||
|
||||
aux := assocArray.Get("ten");
|
||||
Out.LongInt(aux.value,0);Out.Ln;
|
||||
aux := assocArray.Get("eleven");
|
||||
Out.LongInt(aux.value,0);Out.Ln;Out.Ln;
|
||||
|
||||
(* Iterate keys *)
|
||||
iterK := assocArray.IterKeys();
|
||||
WHILE (iterK.Next(k)) DO
|
||||
Out.Object(k);Out.Ln
|
||||
END;
|
||||
|
||||
Out.Ln;
|
||||
|
||||
(* Iterate values *)
|
||||
iterV := assocArray.IterValues();
|
||||
WHILE (iterV.Next(aux)) DO
|
||||
Out.LongInt(aux.value,0);Out.Ln
|
||||
END
|
||||
|
||||
END AssociativeArray.
|
||||
Loading…
Add table
Add a link
Reference in a new issue