algo
Module with some algorithm utility functions.
- class AlgoUtils
Bases:
object
Class container for algorithm utility functions.
- static BinarySearch(arr: List, elem: Any) int
Binary search algorithm simply implemented by using the bisect library.
- Parameters:
arr (list) – list of elements
elem (any) – element to be searched
- Returns:
First index of the element, -1 if not found
- Return type:
int
- static Decode(data: Union[bytes, str], encoding: str = 'utf-8') str
Decode from bytes.
- Parameters:
data (str or bytes) – Data
encoding (str) – Encoding type
- Returns:
String encoded to bytes
- Return type:
str
- Raises:
TypeError – If the data is neither string nor bytes
- static Encode(data: Union[bytes, str], encoding: str = 'utf-8') bytes
Encode to bytes.
- Parameters:
data (str or bytes) – Data
encoding (str) – Encoding type
- Returns:
String encoded to bytes
- Return type:
bytes
- Raises:
TypeError – If the data is neither string nor bytes
- static IsStringMixed(data_str: str) bool
Get if the specified string is in mixed case.
- Parameters:
data_str (str) – string
- Returns:
True if mixed case, false otherwise
- Return type:
bool