"""simple docstring"""



class 	__UpperCAmelCase						:







			'''simple docstring'''





			def __init__( self       ):







										'''simple docstring'''


										A__					:    dict[int, list[int]]														= {}
										# indexmap keys are an index and it's values are the number at that index
										A__					:    dict[int, int]														= {}





			def 		lowerCamelCase				( self      ,			snake_case_      ,			snake_case_       ):







										'''simple docstring'''


										if isinstance(snake_case_      ,			(range, str)       ):
																	A__					:    int														= list(snake_case_       )
										elif not isinstance(snake_case_      ,			snake_case_       ):
																	raise TypeError(
																	    """binary_search_delete() only accepts either a list, range or str"""       )

										A__					:    Dict														= 0
										A__					:    Optional[Any]														= len(snake_case_       ) - 1

										while low <= high:
																	A__					:    int														= (low + high) // 2
																	if array[mid] == item:
																								array.pop(snake_case_       )
																								return array
																	elif array[mid] < item:
																								A__					:    Dict														= mid + 1
																	else:
																								A__					:    Optional[Any]														= mid - 1
										raise ValueError(
										    """Either the item is not in the array or the array was unsorted"""       )





			def 		lowerCamelCase				( self      ,			snake_case_      ,			snake_case_       ):







										'''simple docstring'''


										if isinstance(snake_case_      ,			(range, str)       ):
																	A__					:    Optional[Any]														= list(snake_case_       )
										elif not isinstance(snake_case_      ,			snake_case_       ):
																	raise TypeError(
																	    """binary_search_insert() only accepts either a list, range or str"""       )

										A__					:    Optional[int]														= 0
										A__					:    List[Any]														= len(snake_case_       ) - 1

										while low <= high:
																	A__					:    Union[str, Any]														= (low + high) // 2
																	if array[mid] == index:
																								# If the item already exists in the array,
																								# insert it after the existing item
																								array.insert(mid + 1      ,			snake_case_       )
																								return array
																	elif array[mid] < index:
																								A__					:    Dict														= mid + 1
																	else:
																								A__					:    int														= mid - 1

        # If the item doesn't exist in the array, insert it at the appropriate position
										array.insert(snake_case_      ,			snake_case_       )
										return array





			def 		lowerCamelCase				( self      ,			snake_case_      ,			snake_case_       ):







										'''simple docstring'''


										if index in self.indexmap:
																	A__					:    Optional[int]														= self.indexmap[index]
																	if len(self.numbermap[n]       ) == 1:
																								del self.numbermap[n]
																	else:
																								A__					:    Union[str, Any]														= self.binary_search_delete(self.numbermap[n]      ,			snake_case_       )

        # Set new index
										A__					:    Dict														= number

										# Number not seen before or empty so insert number value
										if number not in self.numbermap:
																	A__					:    Optional[int]														= [index]

										# Here we need to perform a binary search insertion in order to insert
										# The item in the correct place
										else:
																	A__					:    int														= self.binary_search_insert(
																	    self.numbermap[number]      ,			snake_case_       )





			def 		lowerCamelCase				( self      ,			snake_case_       ):







										'''simple docstring'''


										return self.numbermap.get(snake_case_      ,			[-1]       )[0]


if __name__ == "__main__":
				import doctest

				doctest.testmod()






"""simple docstring"""



import enum
import inspect
import warnings
from functools import wraps
from typing import Callable, Optional

from .logging import get_logger


_UpperCamelCase         =		set()
_UpperCamelCase         =		get_logger(__name__)

def    _A(		lowerCAmelCase = None       ):

							def decorator(lowerCAmelCase       ):
														global _emitted_deprecation_warnings

														if inspect.isclass(lowerCAmelCase       ):
																					A__					:    List[Any]														= deprecated_class_or_function.__init__
																					A__					:    Any														= deprecated_class_or_function.__name__
														else:
																					A__					:    Dict														= deprecated_class_or_function
																					A__					:    Optional[int]														= deprecated_function.__name__
																					# Support deprecating __init__ class method: class name instead
																					A__					:    List[str]														= name if name != """__init__""" else deprecated_function.__qualname__.split("""."""       )[-2]

														A__					:    Union[str, Any]														= (
														    F'''{name} is deprecated and will be removed in the next major version of datasets.''' + F''' {help_message}'''
														    if help_message
														    else """"""
														)

														@wraps(lowerCAmelCase       )
														def wrapper(*lowerCAmelCase ,     **lowerCAmelCase       ):
																					A__					:    Tuple														= hash(lowerCAmelCase       )
																					if func_hash not in _emitted_deprecation_warnings:
																												warnings.warn(lowerCAmelCase ,     category=lowerCAmelCase ,     stacklevel=2       )
																												_emitted_deprecation_warnings.add(lowerCAmelCase       )
																					return deprecated_function(*lowerCAmelCase ,     **lowerCAmelCase       )

														A__					:    int														= """deprecated"""

														if inspect.isclass(lowerCAmelCase       ):
																					A__					:    Union[str, Any]														= wrapper
																					return deprecated_class_or_function
														else:
																					return wrapper

							return decorator
class 	__UpperCAmelCase						(enum.EnumMeta    ):







			'''simple docstring'''





			def __getattribute__( cls      ,			snake_case_       ):







										'''simple docstring'''


										A__					:    Union[str, Any]														= super().__getattribute__(snake_case_       )
										if isinstance(snake_case_      ,			enum.Enum       ) and obj._on_access:
																	obj._on_access()
										return obj





			def __getitem__( cls      ,			snake_case_       ):







										'''simple docstring'''


										A__					:    Tuple														= super().__getitem__(snake_case_       )
										if member._on_access:
																	member._on_access()
										return member





			def __call__( cls      ,			snake_case_      ,			snake_case_=None      ,			*, snake_case_=None      ,			snake_case_=None      ,			snake_case_=None      ,			snake_case_=1       ):







										'''simple docstring'''


										A__					:    List[Any]														= super().__call__(snake_case_      ,			snake_case_      ,			module=snake_case_      ,			qualname=snake_case_      ,			type=snake_case_      ,			start=snake_case_       )
										if isinstance(snake_case_      ,			enum.Enum       ) and obj._on_access:
																	obj._on_access()
										return obj





class 	__UpperCAmelCase						(enum.Enum       ,      metaclass=__A    ):







			'''simple docstring'''





			def __new__( cls      ,			snake_case_       ):







										'''simple docstring'''


										A__					:    Tuple														= object.__new__(cls       )
										A__					:    int														= value
										A__					:    Optional[int]														= member.deprecate
										return member





			@property
			def 		lowerCamelCase				( self       ):







										'''simple docstring'''


										return ""





			def 		lowerCamelCase				( self       ):







										'''simple docstring'''


										A__					:    Tuple														= F''' {self.help_message}''' if self.help_message else """"""
										warnings.warn(
										    F'''\'{self.__objclass__.__name__}\' is deprecated and will be removed in the next major version of datasets.'''
										    + help_message      ,			snake_case_      ,			stacklevel=3      ,			)





