2022-11-07 18:06:49 +00:00
|
|
|
# Copyright 2009-2022 Joshua Bronson. All rights reserved.
|
2021-05-08 14:25:29 +00:00
|
|
|
#
|
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
|
|
|
|
|
|
|
# * Code review nav *
|
2022-11-07 18:06:49 +00:00
|
|
|
# (see comments in __init__.py)
|
2021-05-08 14:25:29 +00:00
|
|
|
#==============================================================================
|
|
|
|
#← Prev: _orderedbase.py Current: _frozenordered.py Next: _orderedbidict.py →
|
|
|
|
#==============================================================================
|
|
|
|
|
2022-01-24 04:07:52 +00:00
|
|
|
"""Provide :class:`FrozenOrderedBidict`, an immutable, hashable, ordered bidict."""
|
|
|
|
|
2022-11-07 18:06:49 +00:00
|
|
|
import typing as t
|
2021-05-08 14:25:29 +00:00
|
|
|
|
|
|
|
from ._frozenbidict import frozenbidict
|
|
|
|
from ._orderedbase import OrderedBidictBase
|
2022-01-24 04:07:52 +00:00
|
|
|
from ._typing import KT, VT
|
|
|
|
|
|
|
|
|
|
|
|
class FrozenOrderedBidict(OrderedBidictBase[KT, VT]):
|
|
|
|
"""Hashable, immutable, ordered bidict type.
|
|
|
|
|
|
|
|
Like a hashable :class:`bidict.OrderedBidict`
|
|
|
|
without the mutating APIs, or like a
|
|
|
|
reversible :class:`bidict.frozenbidict` even on Python < 3.8.
|
|
|
|
(All bidicts are order-preserving when never mutated, so frozenbidict is
|
|
|
|
already order-preserving, but only on Python 3.8+, where dicts are
|
|
|
|
reversible, are all bidicts (including frozenbidict) also reversible.)
|
|
|
|
|
|
|
|
If you are using Python 3.8+, frozenbidict gives you everything that
|
|
|
|
FrozenOrderedBidict gives you, but with less space overhead.
|
2022-11-07 18:06:49 +00:00
|
|
|
On the other hand, using FrozenOrderedBidict when you are depending on
|
|
|
|
the ordering of the items can make the ordering dependence more explicit.
|
2022-01-24 04:07:52 +00:00
|
|
|
"""
|
|
|
|
|
2022-11-07 18:06:49 +00:00
|
|
|
__hash__: t.Callable[[t.Any], int] = frozenbidict.__hash__ # pyright: ignore
|
2022-01-24 04:07:52 +00:00
|
|
|
|
2022-11-07 18:06:49 +00:00
|
|
|
if t.TYPE_CHECKING:
|
2022-01-24 04:07:52 +00:00
|
|
|
@property
|
|
|
|
def inverse(self) -> 'FrozenOrderedBidict[VT, KT]': ...
|
|
|
|
|
2021-05-08 14:25:29 +00:00
|
|
|
|
|
|
|
# * Code review nav *
|
|
|
|
#==============================================================================
|
|
|
|
#← Prev: _orderedbase.py Current: _frozenordered.py Next: _orderedbidict.py →
|
|
|
|
#==============================================================================
|