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 unsigned char byte;
12 typedef struct __go_map hmap;
13 typedef struct __go_hash_iter hiter;
15 /* Access a value in a map, returning a value and a presence indicator. */
17 func mapaccess2(h *hmap, key *byte, val *byte) (present bool) {
21 mapval = __go_map_index(h, key, 0);
22 valsize = h->__descriptor->__map_descriptor->__val_type->__size;
24 __builtin_memset(val, 0, valsize);
27 __builtin_memcpy(val, mapval, valsize);
32 /* Optionally assign a value to a map (m[k] = v, p). */
34 func mapassign2(h *hmap, key *byte, val *byte, p bool) {
36 __go_map_delete(h, key);
41 mapval = __go_map_index(h, key, 1);
42 valsize = h->__descriptor->__map_descriptor->__val_type->__size;
43 __builtin_memcpy(mapval, val, valsize);
47 /* Initialize a range over a map. */
49 func mapiterinit(h *hmap, it *hiter) {
50 __go_mapiterinit(h, it);
53 /* Move to the next iteration, updating *HITER. */
55 func mapiternext(it *hiter) {
59 /* Get the key of the current iteration. */
61 func mapiter1(it *hiter, key *byte) {
62 __go_mapiter1(it, key);
65 /* Get the key and value of the current iteration. */
67 func mapiter2(it *hiter, key *byte, val *byte) {
68 __go_mapiter2(it, key, val);