codekingpro/portable-devtools
115k
1"""Sorted Containers -- Sorted List, Sorted Dict, Sorted Set2 3Sorted Containers is an Apache2 licensed containers library, written in4pure-Python, and fast as C-extensions.5 6Python's standard library is great until you need a sorted collections7type. Many will attest that you can get really far without one, but the moment8you **really need** a sorted list, dict, or set, you're faced with a dozen9different implementations, most using C-extensions without great documentation10and benchmarking.11 12In Python, we can do better. And we can do it in pure-Python!13 14::15 16 >>> from sortedcontainers import SortedList17 >>> sl = SortedList(['e', 'a', 'c', 'd', 'b'])18 >>> sl19 SortedList(['a', 'b', 'c', 'd', 'e'])20 >>> sl *= 100000021 >>> sl.count('c')22 100000023 >>> sl[-3:]24 ['e', 'e', 'e']25 >>> from sortedcontainers import SortedDict26 >>> sd = SortedDict({'c': 3, 'a': 1, 'b': 2})27 >>> sd28 SortedDict({'a': 1, 'b': 2, 'c': 3})29 >>> sd.popitem(index=-1)30 ('c', 3)31 >>> from sortedcontainers import SortedSet32 >>> ss = SortedSet('abracadabra')33 >>> ss34 SortedSet(['a', 'b', 'c', 'd', 'r'])35 >>> ss.bisect_left('c')36 237 38Sorted Containers takes all of the work out of Python sorted types - making39your deployment and use of Python easy. There's no need to install a C compiler40or pre-build and distribute custom extensions. Performance is a feature and41testing has 100% coverage with unit tests and hours of stress.42 43:copyright: (c) 2014-2019 by Grant Jenks.44:license: Apache 2.0, see LICENSE for more details.45 46"""47 48 49from .sortedlist import SortedList, SortedKeyList, SortedListWithKey50from .sortedset import SortedSet51from .sorteddict import (52 SortedDict,53 SortedKeysView,54 SortedItemsView,55 SortedValuesView,56)57 58__all__ = [59 'SortedList',60 'SortedKeyList',61 'SortedListWithKey',62 'SortedDict',63 'SortedKeysView',64 'SortedItemsView',65 'SortedValuesView',66 'SortedSet',67]68 69__title__ = 'sortedcontainers'70__version__ = '2.4.0'71__build__ = 0x02040072__author__ = 'Grant Jenks'73__license__ = 'Apache 2.0'74__copyright__ = '2014-2019, Grant Jenks'75 