1discard """ 2sortoutput: true 3output: ''' 4key1: value1 5key2: value2 6key_0: value0 7key_10: value10 8key_11: value11 9key_12: value12 10key_13: value13 11key_14: value14 12key_15: value15 13key_16: value16 14key_17: value17 15key_18: value18 16key_19: value19 17key_20: value20 18key_21: value21 19key_22: value22 20key_23: value23 21key_24: value24 22key_25: value25 23key_26: value26 24key_27: value27 25key_28: value28 26key_29: value29 27key_30: value30 28key_31: value31 29key_32: value32 30key_33: value33 31key_34: value34 32key_35: value35 33key_36: value36 34key_37: value37 35key_38: value38 36key_39: value39 37key_3: value3 38key_40: value40 39key_41: value41 40key_42: value42 41key_43: value43 42key_44: value44 43key_45: value45 44key_46: value46 45key_47: value47 46key_48: value48 47key_49: value49 48key_4: value4 49key_50: value50 50key_51: value51 51key_52: value52 52key_53: value53 53key_54: value54 54key_55: value55 55key_56: value56 56key_57: value57 57key_58: value58 58key_59: value59 59key_5: value5 60key_60: value60 61key_61: value61 62key_62: value62 63key_63: value63 64key_64: value64 65key_65: value65 66key_66: value66 67key_67: value67 68key_68: value68 69key_69: value69 70key_6: value6 71key_70: value70 72key_71: value71 73key_72: value72 74key_73: value73 75key_74: value74 76key_75: value75 77key_76: value76 78key_77: value77 79key_78: value78 80key_79: value79 81key_7: value7 82key_80: value80 83key_8: value8 84key_9: value9 85length of table 0 86length of table 81 87value1 = value2 88''' 89""" 90 91import strtabs 92 93var tab = newStringTable({"key1": "val1", "key2": "val2"}, 94 modeStyleInsensitive) 95for i in 0..80: 96 tab["key_" & $i] = "value" & $i 97 98for key, val in pairs(tab): 99 writeLine(stdout, key, ": ", val) 100writeLine(stdout, "length of table ", $tab.len) 101 102writeLine(stdout, `%`("$key1 = $key2", tab, {useEnvironment})) 103tab.clear 104writeLine(stdout, "length of table ", $tab.len) 105 106block: 107 var x = {"k": "v", "11": "22", "565": "67"}.newStringTable 108 doAssert x["k"] == "v" 109 doAssert x["11"] == "22" 110 doAssert x["565"] == "67" 111 x["11"] = "23" 112 doAssert x["11"] == "23" 113 114 x.clear(modeCaseInsensitive) 115 x["11"] = "22" 116 doAssert x["11"] == "22" 117