Stdlib:Data

This commit is contained in:
Dmitry Boulytchev 2020-08-06 14:56:41 +03:00
parent f6d4a475b4
commit 026158923f
12 changed files with 314 additions and 200 deletions

View file

@ -1,25 +1,21 @@
import Collection;
local a = {1, 2, 3}, b = {1, 2, 3}, t = emptyHashTab ();
local a = {1, 2, 3}, b = {1, 2, 3}, t = emptyHashTab (16, hash, compare);
t := addHashTab (t, a, 100);
validateColl (t);
printf ("HashTab internal structure: %s\n", t.string);
printf ("HashTab internal structure: %s\n", internalOf (t).string);
t := addHashTab (t, b, 200);
validateColl (t);
printf ("HashTab internal structure: %s\n", t.string);
printf ("HashTab internal structure: %s\n", internalOf (t).string);
printf ("Searching: %s\n", findHashTab (t, a).string);
printf ("Searching: %s\n", findHashTab (t, b).string);
t := addHashTab (t, a, 800);
validateColl (t);
printf ("Replaced: %s\n", findHashTab (t, a).string);
t := removeHashTab (t, a);
validateColl (t);
printf ("Restored: %s\n", findHashTab (t, a).string)