Beispiel #1
0
    def remove(self, elem):
        indices = getattr(elem, "indices", None)
        if not indices:
            raise KeyError("%s elem is not in %s.", repr(elem), repr(self))

        for index in indexable.indices(elem):
            del self._backing_dict[index]

        self._elem_count -= 1
Beispiel #2
0
    def add(self, elem):
        duplicate_entry = False
        for index in indexable.indices(elem):
            if index in self._backing_dict:
                duplicate_entry = True

            self._backing_dict[index] = elem

        if not duplicate_entry:
            self._elem_count += 1
Beispiel #3
0
    def __iter__(self):
        seen = set()

        for elem in self._backing_dict.itervalues():
            indices = set(indexable.indices(elem))
            if seen & indices:
                continue

            yield elem
            seen |= indices
Beispiel #4
0
    def add(self, elem):
        duplicate_entry = False
        for index in indexable.indices(elem):
            if index in self._backing_dict:
                duplicate_entry = True

            self._backing_dict[index] = elem

        if not duplicate_entry:
            self._elem_count += 1
Beispiel #5
0
    def __iter__(self):
        seen = set()

        for elem in self._backing_dict.itervalues():
            indices = set(indexable.indices(elem))
            if seen & indices:
                continue

            yield elem
            seen |= indices
Beispiel #6
0
    def indices(self):
        result = set()
        for state in self._delegate:
            result |= frozenset(indexable.indices(state))

        return result
Beispiel #7
0
    def indices(self):
        result = set()
        for state in self._delegate:
            result |= frozenset(indexable.indices(state))

        return result