Search Apps Documentation Source Content File Folder Download Copy Actions Download

crossrealm.gno

0.67 Kb · 38 lines
 1// Package crossrealm_f provides a collection realm for testing cross-realm
 2// ownership scenarios. It uses a nested structure so that intermediate objects
 3// in the ownership chain have RefCount == 1.
 4package crossrealm_f
 5
 6type Entry struct {
 7	Key   string
 8	Value int
 9}
10
11var entries []*Entry
12
13func Add(cur realm, e *Entry) {
14	entries = append(entries, e)
15}
16
17func Remove(cur realm, key string) *Entry {
18	for i, e := range entries {
19		if e.Key == key {
20			entries = append(entries[:i], entries[i+1:]...)
21			return e
22		}
23	}
24	return nil
25}
26
27func Get(key string) *Entry {
28	for _, e := range entries {
29		if e.Key == key {
30			return e
31		}
32	}
33	return nil
34}
35
36func Len() int {
37	return len(entries)
38}