def append(self, i, d): i = base_wrapper.index_from_string(i) d = base_wrapper.data_from_string(d) if list_add is not helpers.not_implemented: self._l = list_add(self._l, i, d) else: self._l = list_append(self._l, i, d)
def add(self, i, d): i = base_wrapper.index_from_string(i) d = base_wrapper.data_from_string(d) try: self._l = list_add(self._l, i, d) except: base_wrapper.index_destroy(i) base_wrapper.data_destroy(d) raise
def search(self, i): i = base_wrapper.index_from_string(i) d = list_search(self._l, i) base_wrapper.index_destroy(i) if d: return base_wrapper.data_to_string(d)
def remove(self, i): i = base_wrapper.index_from_string(i) self._l = list_remove(self._l, i) base_wrapper.index_destroy(i)
def new_pair(self, key, value): i = index_from_string(key) d = data_from_string(value) p = pair_from_index_data(i, d) self.addCleanup(pair_destroy, p) return p
def add(self, i, d): assert i not in self i = base_wrapper.index_from_string(i) d = base_wrapper.data_from_string(d) self._bst = bst_add(self._bst, i, d)
def __contains__(self, i): i = base_wrapper.index_from_string(i) result = bool(bst_search(self._bst, i)) base_wrapper.index_destroy(i) return result