github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/examples/gno.land/p/demo/avl/z_1_filetest.gno (about)

     1  // PKGPATH: gno.land/r/test
     2  package test
     3  
     4  import (
     5  	"gno.land/p/demo/avl"
     6  )
     7  
     8  var node *avl.Node
     9  
    10  func init() {
    11  	node = avl.NewNode("key0", "value0")
    12  	node, _ = node.Set("key1", "value1")
    13  }
    14  
    15  func main() {
    16  	var updated bool
    17  	node, updated = node.Set("key2", "value2")
    18  	// println(node, updated)
    19  	println(updated, node.Size())
    20  }
    21  
    22  // Output:
    23  // false 3
    24  
    25  // Realm:
    26  // switchrealm["gno.land/r/test"]
    27  // c[a8ada09dee16d791fd406d629fe29bb0ed084a30:9]={
    28  //     "Fields": [
    29  //         {
    30  //             "T": {
    31  //                 "@type": "/gno.PrimitiveType",
    32  //                 "value": "16"
    33  //             },
    34  //             "V": {
    35  //                 "@type": "/gno.StringValue",
    36  //                 "value": "key2"
    37  //             }
    38  //         },
    39  //         {
    40  //             "T": {
    41  //                 "@type": "/gno.PrimitiveType",
    42  //                 "value": "16"
    43  //             },
    44  //             "V": {
    45  //                 "@type": "/gno.StringValue",
    46  //                 "value": "value2"
    47  //             }
    48  //         },
    49  //         {
    50  //             "T": {
    51  //                 "@type": "/gno.PrimitiveType",
    52  //                 "value": "64"
    53  //             }
    54  //         },
    55  //         {
    56  //             "N": "AQAAAAAAAAA=",
    57  //             "T": {
    58  //                 "@type": "/gno.PrimitiveType",
    59  //                 "value": "32"
    60  //             }
    61  //         },
    62  //         {
    63  //             "T": {
    64  //                 "@type": "/gno.PointerType",
    65  //                 "Elt": {
    66  //                     "@type": "/gno.RefType",
    67  //                     "ID": "gno.land/p/demo/avl.Node"
    68  //                 }
    69  //             }
    70  //         },
    71  //         {
    72  //             "T": {
    73  //                 "@type": "/gno.PointerType",
    74  //                 "Elt": {
    75  //                     "@type": "/gno.RefType",
    76  //                     "ID": "gno.land/p/demo/avl.Node"
    77  //                 }
    78  //             }
    79  //         }
    80  //     ],
    81  //     "ObjectInfo": {
    82  //         "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:9",
    83  //         "ModTime": "0",
    84  //         "OwnerID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:8",
    85  //         "RefCount": "1"
    86  //     }
    87  // }
    88  // c[a8ada09dee16d791fd406d629fe29bb0ed084a30:8]={
    89  //     "Fields": [
    90  //         {
    91  //             "T": {
    92  //                 "@type": "/gno.PrimitiveType",
    93  //                 "value": "16"
    94  //             },
    95  //             "V": {
    96  //                 "@type": "/gno.StringValue",
    97  //                 "value": "key2"
    98  //             }
    99  //         },
   100  //         {},
   101  //         {
   102  //             "N": "AQAAAAAAAAA=",
   103  //             "T": {
   104  //                 "@type": "/gno.PrimitiveType",
   105  //                 "value": "64"
   106  //             }
   107  //         },
   108  //         {
   109  //             "N": "AgAAAAAAAAA=",
   110  //             "T": {
   111  //                 "@type": "/gno.PrimitiveType",
   112  //                 "value": "32"
   113  //             }
   114  //         },
   115  //         {
   116  //             "T": {
   117  //                 "@type": "/gno.PointerType",
   118  //                 "Elt": {
   119  //                     "@type": "/gno.RefType",
   120  //                     "ID": "gno.land/p/demo/avl.Node"
   121  //                 }
   122  //             },
   123  //             "V": {
   124  //                 "@type": "/gno.PointerValue",
   125  //                 "Base": null,
   126  //                 "Index": "0",
   127  //                 "TV": {
   128  //                     "T": {
   129  //                         "@type": "/gno.RefType",
   130  //                         "ID": "gno.land/p/demo/avl.Node"
   131  //                     },
   132  //                     "V": {
   133  //                         "@type": "/gno.RefValue",
   134  //                         "Hash": "7a8a63e17a567d7b0891ac89d5cd90072a73787d",
   135  //                         "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:6"
   136  //                     }
   137  //                 }
   138  //             }
   139  //         },
   140  //         {
   141  //             "T": {
   142  //                 "@type": "/gno.PointerType",
   143  //                 "Elt": {
   144  //                     "@type": "/gno.RefType",
   145  //                     "ID": "gno.land/p/demo/avl.Node"
   146  //                 }
   147  //             },
   148  //             "V": {
   149  //                 "@type": "/gno.PointerValue",
   150  //                 "Base": null,
   151  //                 "Index": "0",
   152  //                 "TV": {
   153  //                     "T": {
   154  //                         "@type": "/gno.RefType",
   155  //                         "ID": "gno.land/p/demo/avl.Node"
   156  //                     },
   157  //                     "V": {
   158  //                         "@type": "/gno.RefValue",
   159  //                         "Hash": "ab5a297f4eb033d88bdf1677f4dc151ccb9fde9f",
   160  //                         "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:9"
   161  //                     }
   162  //                 }
   163  //             }
   164  //         }
   165  //     ],
   166  //     "ObjectInfo": {
   167  //         "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:8",
   168  //         "ModTime": "0",
   169  //         "OwnerID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:7",
   170  //         "RefCount": "1"
   171  //     }
   172  // }
   173  // c[a8ada09dee16d791fd406d629fe29bb0ed084a30:7]={
   174  //     "Fields": [
   175  //         {
   176  //             "T": {
   177  //                 "@type": "/gno.PrimitiveType",
   178  //                 "value": "16"
   179  //             },
   180  //             "V": {
   181  //                 "@type": "/gno.StringValue",
   182  //                 "value": "key1"
   183  //             }
   184  //         },
   185  //         {},
   186  //         {
   187  //             "N": "AgAAAAAAAAA=",
   188  //             "T": {
   189  //                 "@type": "/gno.PrimitiveType",
   190  //                 "value": "64"
   191  //             }
   192  //         },
   193  //         {
   194  //             "N": "AwAAAAAAAAA=",
   195  //             "T": {
   196  //                 "@type": "/gno.PrimitiveType",
   197  //                 "value": "32"
   198  //             }
   199  //         },
   200  //         {
   201  //             "T": {
   202  //                 "@type": "/gno.PointerType",
   203  //                 "Elt": {
   204  //                     "@type": "/gno.RefType",
   205  //                     "ID": "gno.land/p/demo/avl.Node"
   206  //                 }
   207  //             },
   208  //             "V": {
   209  //                 "@type": "/gno.PointerValue",
   210  //                 "Base": null,
   211  //                 "Index": "0",
   212  //                 "TV": {
   213  //                     "T": {
   214  //                         "@type": "/gno.RefType",
   215  //                         "ID": "gno.land/p/demo/avl.Node"
   216  //                     },
   217  //                     "V": {
   218  //                         "@type": "/gno.RefValue",
   219  //                         "Hash": "627e8e517e7ae5db0f3b753e2a32b607989198b6",
   220  //                         "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:5"
   221  //                     }
   222  //                 }
   223  //             }
   224  //         },
   225  //         {
   226  //             "T": {
   227  //                 "@type": "/gno.PointerType",
   228  //                 "Elt": {
   229  //                     "@type": "/gno.RefType",
   230  //                     "ID": "gno.land/p/demo/avl.Node"
   231  //                 }
   232  //             },
   233  //             "V": {
   234  //                 "@type": "/gno.PointerValue",
   235  //                 "Base": null,
   236  //                 "Index": "0",
   237  //                 "TV": {
   238  //                     "T": {
   239  //                         "@type": "/gno.RefType",
   240  //                         "ID": "gno.land/p/demo/avl.Node"
   241  //                     },
   242  //                     "V": {
   243  //                         "@type": "/gno.RefValue",
   244  //                         "Hash": "fe8afd501233fb95375016199f0443b3c6ab1fbc",
   245  //                         "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:8"
   246  //                     }
   247  //                 }
   248  //             }
   249  //         }
   250  //     ],
   251  //     "ObjectInfo": {
   252  //         "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:7",
   253  //         "ModTime": "0",
   254  //         "OwnerID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:2",
   255  //         "RefCount": "1"
   256  //     }
   257  // }
   258  // u[a8ada09dee16d791fd406d629fe29bb0ed084a30:2]={
   259  //     "Blank": {},
   260  //     "ObjectInfo": {
   261  //         "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:2",
   262  //         "IsEscaped": true,
   263  //         "ModTime": "6",
   264  //         "RefCount": "2"
   265  //     },
   266  //     "Parent": null,
   267  //     "Source": {
   268  //         "@type": "/gno.RefNode",
   269  //         "BlockNode": null,
   270  //         "Location": {
   271  //             "File": "",
   272  //             "Line": "0",
   273  //             "Nonce": "0",
   274  //             "PkgPath": "gno.land/r/test"
   275  //         }
   276  //     },
   277  //     "Values": [
   278  //         {
   279  //             "T": {
   280  //                 "@type": "/gno.FuncType",
   281  //                 "Params": [],
   282  //                 "Results": []
   283  //             },
   284  //             "V": {
   285  //                 "@type": "/gno.FuncValue",
   286  //                 "Closure": {
   287  //                     "@type": "/gno.RefValue",
   288  //                     "Escaped": true,
   289  //                     "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:3"
   290  //                 },
   291  //                 "FileName": "main.gno",
   292  //                 "IsMethod": false,
   293  //                 "Name": "init.0",
   294  //                 "NativeName": "",
   295  //                 "NativePkg": "",
   296  //                 "PkgPath": "gno.land/r/test",
   297  //                 "Source": {
   298  //                     "@type": "/gno.RefNode",
   299  //                     "BlockNode": null,
   300  //                     "Location": {
   301  //                         "File": "main.gno",
   302  //                         "Line": "10",
   303  //                         "Nonce": "0",
   304  //                         "PkgPath": "gno.land/r/test"
   305  //                     }
   306  //                 },
   307  //                 "Type": {
   308  //                     "@type": "/gno.FuncType",
   309  //                     "Params": [],
   310  //                     "Results": []
   311  //                 }
   312  //             }
   313  //         },
   314  //         {
   315  //             "T": {
   316  //                 "@type": "/gno.FuncType",
   317  //                 "Params": [],
   318  //                 "Results": []
   319  //             },
   320  //             "V": {
   321  //                 "@type": "/gno.FuncValue",
   322  //                 "Closure": {
   323  //                     "@type": "/gno.RefValue",
   324  //                     "Escaped": true,
   325  //                     "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:3"
   326  //                 },
   327  //                 "FileName": "main.gno",
   328  //                 "IsMethod": false,
   329  //                 "Name": "main",
   330  //                 "NativeName": "",
   331  //                 "NativePkg": "",
   332  //                 "PkgPath": "gno.land/r/test",
   333  //                 "Source": {
   334  //                     "@type": "/gno.RefNode",
   335  //                     "BlockNode": null,
   336  //                     "Location": {
   337  //                         "File": "main.gno",
   338  //                         "Line": "15",
   339  //                         "Nonce": "0",
   340  //                         "PkgPath": "gno.land/r/test"
   341  //                     }
   342  //                 },
   343  //                 "Type": {
   344  //                     "@type": "/gno.FuncType",
   345  //                     "Params": [],
   346  //                     "Results": []
   347  //                 }
   348  //             }
   349  //         },
   350  //         {
   351  //             "T": {
   352  //                 "@type": "/gno.PointerType",
   353  //                 "Elt": {
   354  //                     "@type": "/gno.RefType",
   355  //                     "ID": "gno.land/p/demo/avl.Node"
   356  //                 }
   357  //             },
   358  //             "V": {
   359  //                 "@type": "/gno.PointerValue",
   360  //                 "Base": null,
   361  //                 "Index": "0",
   362  //                 "TV": {
   363  //                     "T": {
   364  //                         "@type": "/gno.RefType",
   365  //                         "ID": "gno.land/p/demo/avl.Node"
   366  //                     },
   367  //                     "V": {
   368  //                         "@type": "/gno.RefValue",
   369  //                         "Hash": "c5eefc40ed065461b4a920c1349ed734ffdead8f",
   370  //                         "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:7"
   371  //                     }
   372  //                 }
   373  //             }
   374  //         }
   375  //     ]
   376  // }
   377  // d[a8ada09dee16d791fd406d629fe29bb0ed084a30:4]