Relational Algebra Engine
Loading...
Searching...
No Matches
Classes | Functions
tuple.c File Reference

Tuple implementation for the Relational Algebra Engine. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "tuple.h"
Include dependency graph for tuple.c:

Classes

struct  FindAttributeContext
 
struct  TupleEqualsContext
 

Functions

Tuple * tuple_create (void)
 Create a new Tuple.
 
void tuple_destroy (Tuple *t)
 Destroy a Tuple and free its memory.
 
int tuple_add_attribute (Tuple *t, Attribute *attr)
 Add an Attribute to a Tuple.
 
void tuple_print (const Tuple *t)
 Print a Tuple to stdout.
 
Attribute * tuple_find_attribute (Tuple *t, const char *name)
 Find an Attribute in a Tuple by name.
 
int tuple_equals (Tuple *a, Tuple *b)
 Check if two Tuples are equal (all attributes match).
 

Detailed Description

Tuple implementation for the Relational Algebra Engine.

Handles creation, destruction, and comparison of tuples, which are sets of attributes and serve as the elements of relations in the relational model.

Function Documentation

◆ tuple_add_attribute()

int tuple_add_attribute ( Tuple *  t,
Attribute *  attr 
)

Add an Attribute to a Tuple.

Parameters
tPointer to the Tuple.
attrPointer to the Attribute to add.
Returns
1 if added, 0 if already present, -1 on error.

◆ tuple_create()

Tuple * tuple_create ( void  )

Create a new Tuple.

Returns
Pointer to new Tuple, or NULL on failure.

◆ tuple_destroy()

void tuple_destroy ( Tuple *  t)

Destroy a Tuple and free its memory.

Parameters
tPointer to the Tuple to destroy.

◆ tuple_equals()

int tuple_equals ( Tuple *  a,
Tuple *  b 
)

Check if two Tuples are equal (all attributes match).

Parameters
aPointer to first Tuple.
bPointer to second Tuple.
Returns
1 if equal, 0 otherwise.

◆ tuple_find_attribute()

Attribute * tuple_find_attribute ( Tuple *  t,
const char *  name 
)

Find an Attribute in a Tuple by name.

Parameters
tPointer to the Tuple.
nameName of the Attribute to find.
Returns
Pointer to the found Attribute, or NULL if not found.

◆ tuple_print()

void tuple_print ( const Tuple *  t)

Print a Tuple to stdout.

Parameters
tPointer to the Tuple to print.