mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Since the theater commander runs once per campaign action, missions that do not have aircraft available may be checked more than once a turn. Without deduping requests this can lead to cases where the AI buys dozens of tankers on turn 0. Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1470
24 lines
662 B
Python
24 lines
662 B
Python
from collections import Iterator, Iterable
|
|
from typing import Generic, TypeVar, Optional
|
|
|
|
ValueT = TypeVar("ValueT")
|
|
|
|
|
|
class OrderedSet(Generic[ValueT]):
|
|
def __init__(self, initial_data: Optional[Iterable[ValueT]] = None) -> None:
|
|
if initial_data is None:
|
|
initial_data = []
|
|
self._data: dict[ValueT, None] = {v: None for v in initial_data}
|
|
|
|
def __iter__(self) -> Iterator[ValueT]:
|
|
yield from self._data
|
|
|
|
def __contains__(self, item: ValueT) -> bool:
|
|
return item in self._data
|
|
|
|
def add(self, item: ValueT) -> None:
|
|
self._data[item] = None
|
|
|
|
def clear(self) -> None:
|
|
self._data.clear()
|