66 lines
1.4 KiB
C
66 lines
1.4 KiB
C
#ifndef NODES_H
|
|
#define NODES_H
|
|
|
|
#include "utils.h"
|
|
|
|
typedef struct Node {
|
|
int128_t a, b, c;
|
|
char move;
|
|
struct Node* parent;
|
|
struct Node* next;
|
|
} Node;
|
|
|
|
/**
|
|
* @brief Initializes the node pool with a specified maximum number of nodes
|
|
* @param max_nodes The maximum number of nodes the pool can hold
|
|
*/
|
|
void node_pool_init(int max_nodes);
|
|
|
|
/**
|
|
* @brief Allocates a node from the pool
|
|
* @return A pointer to the allocated node, or NULL if the pool is exhausted
|
|
*/
|
|
Node* node_pool_alloc();
|
|
|
|
/**
|
|
* @brief Resets the node pool without freeing memory
|
|
*/
|
|
void node_pool_reset();
|
|
|
|
/**
|
|
* @brief Frees the node pool memory
|
|
*/
|
|
void node_pool_destroy();
|
|
|
|
/**
|
|
* @brief Returns the current usage of the node pool
|
|
* @return The number of nodes currently allocated from the pool
|
|
*/
|
|
int node_pool_usage();
|
|
|
|
/**
|
|
* @brief Tries to push child nodes based on the current node's move
|
|
* @param curr The current node
|
|
*/
|
|
void try_push_children(Node* curr);
|
|
|
|
typedef struct VisitedEntry {
|
|
int128_t a, b, c;
|
|
struct VisitedEntry* next;
|
|
} VisitedEntry;
|
|
|
|
/**
|
|
* @brief Marks a triplet as visited and checks if it's new
|
|
* @param a The first integer of the triplet
|
|
* @param b The second integer of the triplet
|
|
* @param c The third integer of the triplet
|
|
* @return 1 if the triplet is new and marked, 0 if it was already visited
|
|
*/
|
|
int visit_and_mark(int128_t a, int128_t b, int128_t c);
|
|
|
|
/**
|
|
* @brief Clears the hash table
|
|
*/
|
|
void clear_hash_table();
|
|
|
|
#endif /* NODES_H */ |