1 // Copyright 2010 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
9 typedef struct __go_map Hmap;
10 typedef struct __go_hash_iter hiter;
12 /* Access a value in a map, returning a value and a presence indicator. */
14 func mapaccess2(t *MapType, h *Hmap, key *byte, val *byte) (present bool) {
18 mapval = __go_map_index(h, key, 0);
19 valsize = t->__val_type->__size;
21 __builtin_memset(val, 0, valsize);
24 __builtin_memcpy(val, mapval, valsize);
29 /* Optionally assign a value to a map (m[k] = v, p). */
31 func mapassign2(h *Hmap, key *byte, val *byte, p bool) {
33 __go_map_delete(h, key);
38 mapval = __go_map_index(h, key, 1);
39 valsize = h->__descriptor->__map_descriptor->__val_type->__size;
40 __builtin_memcpy(mapval, val, valsize);
44 /* Delete a key from a map. */
46 func mapdelete(h *Hmap, key *byte) {
47 __go_map_delete(h, key);
50 /* Initialize a range over a map. */
52 func mapiterinit(h *Hmap, it *hiter) {
53 __go_mapiterinit(h, it);
56 /* Move to the next iteration, updating *HITER. */
58 func mapiternext(it *hiter) {
62 /* Get the key of the current iteration. */
64 func mapiter1(it *hiter, key *byte) {
65 __go_mapiter1(it, key);
68 /* Get the key and value of the current iteration. */
70 func mapiter2(it *hiter, key *byte, val *byte) {
71 __go_mapiter2(it, key, val);