src.pydasa.structs.tables.htme#

Module to represent the MapEntry data structure for the Hash Table in PyDASA.

classes:

MapEntry: Represents a key-value pair in a hash table with type validation and error handling.

IMPORTANT: based on the implementations proposed by the following authors/books:

# . Algorithms, 4th Edition, Robert Sedgewick and Kevin Wayne. # . Data Structure and Algorithms in Python, M.T. Goodrich, R. Tamassia, M.H. Goldwasser.

Classes#

MapEntry

MapEntry class for creating a map entry in the Hash Table. Fundamental for the Hash Table data structure.

Module Contents#

class src.pydasa.structs.tables.htme.MapEntry#

Bases: Generic[pydasa.structs.types.generics.T]

MapEntry class for creating a map entry in the Hash Table. Fundamental for the Hash Table data structure.

Parameters:

Generic (T) – Generic type for a Python data structure.

Returns:

A map entry object with the following attributes:
  • _key: The key of the map entry.

  • _value: The value of the map entry.

Return type:

MapEntry

_key: pydasa.structs.types.generics.T | None = None#

Es la llave del registro del mapa.

_value: pydasa.structs.types.generics.T | None = None#

Es el valor del registro del mapa.

_error_handler(err)#

_error_handler() to process the context (package/class), function name (method), and the error (exception) that was raised to format a detailed error message and traceback.

Parameters:

err (Exception) – Python raised exception.

Return type:

None

_validate_key_type(key)#

_validate_key_type() checks if the type of the key is the same as the type of the MapEntry.

Parameters:

key (T) – _key to process in the MapEntry.

Raises:

TypeError – error if the type of the key to be added is not the same as the type of the keys already contained in the MapEntry.

Returns:

True if the type of the key is the same as the type of the MapEntry.

Return type:

bool

_validate_value_type(value)#

_validate_value_type() checks if the type of the value is the same as the type of the MapEntry.

Parameters:

value (T) – value to process in the MapEntry.

Raises:

TypeError – error if the type of the value to be added is not the same as the type of the values already contained in the MapEntry.

Returns:

True if the type of the value is the same as the type of the MapEntry.

Return type:

bool

property key: pydasa.structs.types.generics.T | None#

key Property to read the key in the MapEntry. Acts as a getter (get()) for the _key attribute.

Returns:

recovered key in the MapEntry. None if the key is not set.

Return type:

Optional[T]

property value: pydasa.structs.types.generics.T | None#

value Property to read the value in the MapEntry. Acts as a getter (get()) for the _value attribute.

Returns:

recovered value in the MapEntry. None if the value is not set.

Return type:

Optional[T]