summaryrefslogtreecommitdiffstatshomepage
path: root/py/objset.c
diff options
context:
space:
mode:
authorJohn R. Lenton <jlenton@gmail.com>2014-01-12 15:44:26 +0000
committerJohn R. Lenton <jlenton@gmail.com>2014-01-12 15:44:26 +0000
commit1d7fb2f21be8dd6f95e5889442a3735464c94dfb (patch)
treed699ffd73623eaa86cd9adba4f605ffb2750605b /py/objset.c
parent19b14d3d8ae229f17f8b63825f96220db37e3770 (diff)
downloadmicropython-1d7fb2f21be8dd6f95e5889442a3735464c94dfb.tar.gz
micropython-1d7fb2f21be8dd6f95e5889442a3735464c94dfb.zip
Implemented set.clear
Diffstat (limited to 'py/objset.c')
-rw-r--r--py/objset.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/py/objset.c b/py/objset.c
index a74d1eb6a3..8bd006a761 100644
--- a/py/objset.c
+++ b/py/objset.c
@@ -104,6 +104,16 @@ static mp_obj_t set_add(mp_obj_t self_in, mp_obj_t item) {
}
static MP_DEFINE_CONST_FUN_OBJ_2(set_add_obj, set_add);
+static mp_obj_t set_clear(mp_obj_t self_in) {
+ assert(MP_OBJ_IS_TYPE(self_in, &set_type));
+ mp_obj_set_t *self = self_in;
+
+ mp_set_clear(&self->set);
+
+ return mp_const_none;
+}
+static MP_DEFINE_CONST_FUN_OBJ_1(set_clear_obj, set_clear);
+
/******************************************************************************/
/* set constructors & public C API */
@@ -111,6 +121,7 @@ static MP_DEFINE_CONST_FUN_OBJ_2(set_add_obj, set_add);
static const mp_method_t set_type_methods[] = {
{ "add", &set_add_obj },
+ { "clear", &set_clear_obj },
{ NULL, NULL }, // end-of-list sentinel
};