"""
Generate a table of unique items.
The `UniqueTable` class collects items into an array, removing duplicates. Each
item is mapped to its offset in the final array.
This is a compression technique for compile-time generated tables.
"""
# noqa
pass
"""
Collect items into the `table` list, removing duplicates.
"""
# type: () -> None
# List of items added in order.
= # type: List[Any]
# Map item -> index.
= # type: Dict[Any, int]
# type: (Any) -> int
"""
Add a single item to the table if it isn't already there.
Return the offset into `self.table` of the item.
"""
return
=
=
return
"""
Collect sequences into the `table` list, removing duplicates.
Sequences don't have to be of the same length.
"""
# type: () -> None
= # type: List[Any]
# Map seq -> index.
= # type: Dict[Tuple[Any, ...], int]
# type: (Sequence[Any]) -> int
"""
Add a sequence of items to the table. If the table already contains the
items in `seq` in the same order, use those instead.
Return the offset into `self.table` of the beginning of `seq`.
"""
return 0
=
return
=
# Add seq and all sub-sequences to `index`.
= # type: Dict[Tuple[Any, ...], int]
assert is not None
=
= +
return