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