Does Python have an ordered set?

前端 未结 14 1340
予麋鹿
予麋鹿 2020-11-21 13:20

Python has an ordered dictionary. What about an ordered set?

14条回答
  •  礼貌的吻别
    2020-11-21 13:54

    There's no OrderedSet in official library. I make an exhaustive cheatsheet of all the data structure for your reference.

    DataStructure = {
        'Collections': {
            'Map': [
                ('dict', 'OrderDict', 'defaultdict'),
                ('chainmap', 'types.MappingProxyType')
            ],
            'Set': [('set', 'frozenset'), {'multiset': 'collection.Counter'}]
        },
        'Sequence': {
            'Basic': ['list', 'tuple', 'iterator']
        },
        'Algorithm': {
            'Priority': ['heapq', 'queue.PriorityQueue'],
            'Queue': ['queue.Queue', 'multiprocessing.Queue'],
            'Stack': ['collection.deque', 'queue.LifeQueue']
            },
        'text_sequence': ['str', 'byte', 'bytearray']
    }
    

提交回复
热议问题