dmlfw (Daniyal Machine Learning Framework)
example_set_string.c

Typical usage:

#include <stdio.h>
#include <stdlib.h>
#include <dmlfw_set.h>
#include <dmlfw_error.h>
int main(void) {
char err[512], dbg[512];
if (dmlfw_error()) {
dmlfw_get_error_string(err, sizeof(err));
dmlfw_get_debug_string(dbg, sizeof(dbg));
printf("Failed to create set: %s\nDebug info: %s\n", err, dbg);
return EXIT_FAILURE;
}
if (dmlfw_set_string_add(set, "example") == -1 && dmlfw_error()) {
dmlfw_get_error_string(err, sizeof(err));
dmlfw_get_debug_string(dbg, sizeof(dbg));
printf("Failed to add string: %s\nDebug info: %s\n", err, dbg);
return EXIT_FAILURE;
}
char *retrieved = NULL;
dmlfw_set_string_get(set, 0, &retrieved);
if (dmlfw_error()) {
dmlfw_get_error_string(err, sizeof(err));
dmlfw_get_debug_string(dbg, sizeof(dbg));
printf("Failed to get string: %s\nDebug info: %s\n", err, dbg);
} else {
printf("First string in set: %s\n", retrieved);
free(retrieved);
}
printf("Set size: %u\n", size);
return EXIT_SUCCESS;
}
int main()
Main function to execute batch gradient descent linear regression example.
Definition batch_gd.c:316
Centralized error handling interface for the framework.
void dmlfw_get_error_string(char *error_string, uint32_t size)
Copies the last error message into the provided character buffer.
uint8_t dmlfw_error(void)
Checks if the last framework call resulted in an error.
void dmlfw_get_debug_string(char *debug_string, uint32_t size)
Copies detailed debug information about the last error into the provided character buffer.
Core unordered set types and utilities for string data.
dmlfw_set_string * dmlfw_set_string_create_new(void)
Creates an empty unordered set of strings.
dimension_t dmlfw_set_string_get_size(dmlfw_set_string *set)
Retrieves the number of unique strings in the set.
void dmlfw_set_string_get(dmlfw_set_string *set, index_t i, char **string)
Retrieves a copy of the string at the given index.
struct __dmlfw_set_string dmlfw_set_string
Opaque structure representing an unordered set of unique strings.
Definition dmlfw_set_string.h:84
int dmlfw_set_string_add(dmlfw_set_string *set, char *string)
Adds a unique string to the set.
void dmlfw_set_string_destroy(dmlfw_set_string *set)
Destroys the string set, freeing all resources.
uint32_t dimension_t
Represents the size or dimension of a data structure (uint32_t).
Definition dmlfw_types.h:26