How to use the sortedcontainers.sortedset.SortedSet function in sortedcontainers

To help you get started, we’ve selected a few sortedcontainers examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Nic30 / hdlConvertor / utils / antlr4 / left_recurse_remove.py View on Github external
def get_terminals(rules):
    terminals = SortedSet()

    def collect_terminals(obj: iAntlr4GramElem):
        if isinstance(obj, Antlr4Symbol) and obj.is_terminal:
            terminals.add(obj.symbol)

    for r in rules:
        r.walk(collect_terminals)

    return terminals
github ebu / ebu-tt-live-toolkit / ebu_tt_live / documents / ebutt3.py View on Github external
def __init__(self, sequence_identifier, reference_clock, lang, verbose=False, authors_group_identifier=None):
        self._sequence_identifier = sequence_identifier
        self._authors_group_identifier = authors_group_identifier
        self._reference_clock = reference_clock
        self._lang = lang
        self._last_sequence_number = 0
        # The documents are kept in a sorted set that is sorted by the documents's sequence number
        self._documents = sortedset.SortedSet(key=lambda x: x.sequence_number)
        self._verbose = verbose
github Nic30 / hdlConvertor / utils / antlr4 / left_recurse_remove.py View on Github external
"""
    direct left corner:
       The Symbol X is a direct left corner of a nonterminal A,
       if there is an A-production with X as the left-most symbol on the right-hand side.
       We define the left-corner relation to be the reflexive transitive closure
       of the direct-left-corner relation and we define theproper-left-corner relation
       to be the transitive closure ofthe direct-left-corner relation.

       (A nonterminal is left re-cursive if it is a proper left corner of itself.)

       (A nonterminal is directly left recursive if it is a direct left corner of itself
        and a nonterminal is indirectly left recursiveif it is left recursive,
        but not directly left recursive.)
       :note: | in rules is not taken in account
    """
    dlc = SortedSet()
    can_be_eps = _direct_left_corner(
        rule.body, dlc, allow_eps_in_sel=allow_eps_in_sel)
    if not allow_eps_in_sel:
        assert not can_be_eps, rule
    return dlc
github grantjenks / python-sortedcontainers / sortedcontainers / sortedset.py View on Github external
def comparer(self, other):
            "Compare method for sorted set and set."
            if isinstance(other, SortedSet):
                return set_op(self._set, other._set)
            elif isinstance(other, Set):
                return set_op(self._set, other)
            return NotImplemented
github albertz / PyCParser / interpreter.py View on Github external
self._cStateWrapper.IndirectSimpleCTypes = True
        self._cStateWrapper.error = self._cStateWrapperError
        self.globalScope = GlobalScope(self, self._cStateWrapper)
        self._func_cache = {}
        self.globalsWrapper = GlobalsWrapper(self.globalScope)
        self.globalsStructWrapper = GlobalsTypeWrapper(self.globalScope, "structs")
        self.globalsUnionsWrapper = GlobalsTypeWrapper(self.globalScope, "unions")
        self.wrappedValues = WrappedValues()  # attrib -> obj
        self.ctypes_wrapped = CTypesWrapper()
        self.helpers = Helpers(self)
        self.mallocs = {}  # ptr addr -> ctype obj
        # Note: The pointerStorage will only weakly ref the ctype objects.
        # When the real ctype objects go out of scope, we don't want to
        # keep them alive.
        self.pointerStorage = WeakValueDictionary()  # ptr addr -> weak ctype obj ref
        self.pointerStorageRanges = SortedSet()  # (ptr-addr,size) tuples
        # Here we hold constant strings, because they need some global
        # storage which will not get freed.
        self.constStrings = {}  # str -> ctype c_char_p
        self.globalsDict = {
            "ctypes": ctypes,
            "ctypes_wrapped": self.ctypes_wrapped,
            "helpers": self.helpers,
            "g": self.globalsWrapper,
            "structs": self.globalsStructWrapper,
            "unions": self.globalsUnionsWrapper,
            "values": self.wrappedValues,
            "intp": self
        }
        self.debug_print_getFunc = False
        self.debug_print_getVar = False
github Ezibenroc / PyRoaringBitMap / quick_bench.py View on Github external
classes = {'set': set, 'pyroaring': BitMap}
nb_exp = 30
size = int(1e6)
density = 0.125
universe_size = int(size/density)

try:
    from roaringbitmap import RoaringBitmap
    classes['roaringbitmap'] = RoaringBitmap
except ImportError:
    sys.stderr.write('Warning: could not import roaringbitmap\n')
    sys.stderr.write('         see https://github.com/andreasvc/roaringbitmap/\n')

try:
    from sortedcontainers.sortedset import SortedSet
    classes['sortedcontainers'] = SortedSet
except ImportError:
    sys.stderr.write('Warning: could not import sortedcontainers\n')
    sys.stderr.write('         see https://github.com/grantjenks/sorted_containers\n')

try:
    from croaring import BitSet
    classes['python-croaring'] = BitSet
except ImportError:
    sys.stderr.write('Warning: could not import croaring\n')
    sys.stderr.write('         see https://github.com/sunzhaoping/python-croaring\n')

import_str = 'import array, pickle; from __main__ import %s' % (','.join(
    ['get_list', 'get_range', 'random', 'size', 'universe_size'] +
    [cls.__name__ for cls in classes.values() if cls is not set]))