-
Notifications
You must be signed in to change notification settings - Fork 1
/
map.h
69 lines (57 loc) · 1.6 KB
/
map.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// -*- mode:c++ -*-
#ifndef ICI_MAP_H
#define ICI_MAP_H
#include "object.h"
namespace ici
{
/*
* The following portion of this file exports to ici.h. --ici.h-start--
*/
struct slot
{
object *sl_key;
object *sl_value;
};
struct map : objwsup
{
size_t s_nels; /* How many slots used. */
size_t s_nslots; /* How many slots allocated. */
slot *s_slots;
};
inline map *mapof(object *o)
{
return o->as<map>();
}
inline bool ismap(object *o)
{
return o->hastype(TC_MAP);
}
class map_type : public type
{
public:
map_type() : type("map", sizeof(map))
{
}
size_t mark(object *o) override;
void free(object *o) override;
unsigned long hash(object *o) override;
int cmp(object *o1, object *o2) override;
object *copy(object *o) override;
int assign_super(object *o, object *k, object *v, map *b) override;
int assign(object *o, object *k, object *v) override;
int assign_base(object *o, object *k, object *v) override;
int forall(object *o) override;
object *fetch(object *o, object *k) override;
object *fetch_base(object *o, object *k) override;
int fetch_super(object *o, object *k, object **pv, map *b) override;
int save(archiver *, object *) override;
object *restore(archiver *) override;
int64_t len(object *) override;
int nkeys(object *) override;
int keys(object *, array *) override;
};
/*
* End of ici.h export. --ici.h-end--
*/
} // namespace ici
#endif /* ICI_MAP_H */