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_type MapType;
13 typedef struct __go_map Hmap;
14 typedef struct __go_hash_iter hiter;
16 /* Access a value in a map, returning a value and a presence indicator. */
18 func mapaccess2(t *MapType, h *Hmap, key *byte, val *byte) (present bool) {
22 mapval = __go_map_index(h, key, 0);
23 valsize = t->__val_type->__size;
25 __builtin_memset(val, 0, valsize);
28 __builtin_memcpy(val, mapval, valsize);
33 /* Optionally assign a value to a map (m[k] = v, p). */
35 func mapassign2(h *Hmap, key *byte, val *byte, p bool) {
37 __go_map_delete(h, key);
42 mapval = __go_map_index(h, key, 1);
43 valsize = h->__descriptor->__map_descriptor->__val_type->__size;
44 __builtin_memcpy(mapval, val, valsize);
48 /* Delete a key from a map. */
50 func mapdelete(h *Hmap, key *byte) {
51 __go_map_delete(h, key);
54 /* Initialize a range over a map. */
56 func mapiterinit(h *Hmap, it *hiter) {
57 __go_mapiterinit(h, it);
60 /* Move to the next iteration, updating *HITER. */
62 func mapiternext(it *hiter) {
66 /* Get the key of the current iteration. */
68 func mapiter1(it *hiter, key *byte) {
69 __go_mapiter1(it, key);
72 /* Get the key and value of the current iteration. */
74 func mapiter2(it *hiter, key *byte, val *byte) {
75 __go_mapiter2(it, key, val);