Autopysta
Loading...
Searching...
No Matches
diccionario.h File Reference

Defines the Diccionario and Nodo structs for key-value dictionary management. More...

Go to the source code of this file.

Classes

struct  Nodo
 Struct representing a node in the dictionary. More...
 
struct  Diccionario
 Struct representing the dictionary. More...
 

Typedefs

typedef struct Diccionario Diccionario
 
typedef struct Nodo Nodo
 

Functions

Diccionariodiccionario_nuevo (void)
 Creates a new empty dictionary.
 
void diccionario_agrega (Diccionario *D, const char *new_name, double new_value)
 Adds a new key-value pair to the dictionary.
 
void diccionario_muestra (const Diccionario *D)
 Displays the contents of the dictionary.
 
void diccionario_aumenta (Diccionario **D, int unidades)
 Increases the size of the dictionary by a given number of units.
 
void diccionario_libera (Diccionario *D)
 Frees the memory allocated for the dictionary.
 
void diccionario_copia (const Diccionario *Do, Diccionario *Dd, int cantidad)
 Copies the contents of one dictionary into another.
 
void diccionario_inicializa_contenido (Diccionario *D)
 Initializes the contents of the dictionary.
 
double diccionario_busca_significado (Diccionario *D, const char *nombre)
 Searches for the value associated with a key in the dictionary.
 

Detailed Description

Defines the Diccionario and Nodo structs for key-value dictionary management.

Author
Date
11 Dec 2019

This file provides the data structures and functions needed to manage a simple key-value dictionary, where each key is a string and the value is a double.

Function Documentation

◆ diccionario_agrega()

void diccionario_agrega ( Diccionario * D,
const char * new_name,
double new_value )

Adds a new key-value pair to the dictionary.

Parameters
DPointer to the dictionary where the key-value pair will be added.
new_nameKey for the new node to be added.
new_valueValue corresponding to the new key.

◆ diccionario_aumenta()

void diccionario_aumenta ( Diccionario ** D,
int unidades )

Increases the size of the dictionary by a given number of units.

Parameters
DPointer to the dictionary to be increased in size.
unidadesThe number of additional nodes to allocate.

◆ diccionario_busca_significado()

double diccionario_busca_significado ( Diccionario * D,
const char * nombre )

Searches for the value associated with a key in the dictionary.

Parameters
DPointer to the dictionary.
nombreThe key to search for.
Returns
The value corresponding to the key if found; otherwise, returns 0.

◆ diccionario_copia()

void diccionario_copia ( const Diccionario * Do,
Diccionario * Dd,
int cantidad )

Copies the contents of one dictionary into another.

Parameters
DoPointer to the original dictionary (source).
DdPointer to the destination dictionary.
cantidadThe number of nodes to copy.

◆ diccionario_inicializa_contenido()

void diccionario_inicializa_contenido ( Diccionario * D)

Initializes the contents of the dictionary.

Parameters
DPointer to the dictionary whose contents will be initialized.

◆ diccionario_libera()

void diccionario_libera ( Diccionario * D)

Frees the memory allocated for the dictionary.

Parameters
DPointer to the dictionary to be deleted.

◆ diccionario_muestra()

void diccionario_muestra ( const Diccionario * D)

Displays the contents of the dictionary.

Parameters
DPointer to the dictionary whose contents will be displayed.

◆ diccionario_nuevo()

Diccionario * diccionario_nuevo ( void )

Creates a new empty dictionary.

Allocates memory for a new Diccionario and initializes it with no nodes.

Returns
Pointer to the newly created dictionary.