tetengo 1.8.1
A multipurpose library set
Loading...
Searching...
No Matches
constraint.h File Reference

A constraint. More...

#include <stdbool.h>
#include <stddef.h>
#include <tetengo/lattice/constraintElement.h>
#include <tetengo/lattice/node.h>
+ Include dependency graph for constraint.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

tetengo_lattice_constraint_t * tetengo_lattice_constraint_createEmpty ()
 Creates an empty constraint.
 
tetengo_lattice_constraint_t * tetengo_lattice_constraint_create (tetengo_lattice_constraintElement_t *const *pp_pattern, size_t pattern_length)
 Creates a constraint.
 
void tetengo_lattice_constraint_destroy (const tetengo_lattice_constraint_t *p_constraint)
 Destroys a constraint.
 
bool tetengo_lattice_constraint_matches (const tetengo_lattice_constraint_t *p_constraint, const tetengo_lattice_node_t *p_reverse_path, size_t path_length)
 Returns true when the path matches the pattern.
 
bool tetengo_lattice_constraint_matchesTail (const tetengo_lattice_constraint_t *p_constraint, const tetengo_lattice_node_t *p_reverse_tail_path, size_t tail_path_length)
 Returns true when the tail path matches the tail of the pattern.
 

Detailed Description

A constraint.

Copyright (C) 2019-2023 kaoru https://www.tetengo.org/

Function Documentation

◆ tetengo_lattice_constraint_create()

tetengo_lattice_constraint_t * tetengo_lattice_constraint_create ( tetengo_lattice_constraintElement_t *const *  pp_pattern,
size_t  pattern_length 
)

Creates a constraint.

The ownership of the constraint elements pointed by pp_pattern is transferred into the constraint. There is no need to destroy the constraint elements after calling this function. But the array holding the constraint elements must be destroyed outside this function.

Parameters
pp_patternA pointer to an array of pointers to constraint elements.
pattern_lengthA pattern length.
Returns
A pointer to constraint. Or NULL when pp_pattern is NULL or has NULL constraint elements.

◆ tetengo_lattice_constraint_createEmpty()

tetengo_lattice_constraint_t * tetengo_lattice_constraint_createEmpty ( )

Creates an empty constraint.

It matches any path.

Returns
A pointer to an empty constraint.

◆ tetengo_lattice_constraint_destroy()

void tetengo_lattice_constraint_destroy ( const tetengo_lattice_constraint_t *  p_constraint)

Destroys a constraint.

Parameters
p_constraintA pointer to a constraint.

◆ tetengo_lattice_constraint_matches()

bool tetengo_lattice_constraint_matches ( const tetengo_lattice_constraint_t *  p_constraint,
const tetengo_lattice_node_t p_reverse_path,
size_t  path_length 
)

Returns true when the path matches the pattern.

Parameters
p_constraintA pointer to a constraint.
p_reverse_pathA pointer to a path in reverse order.
path_lengthA path length.
Return values
trueWhen the path matches the pattern.
falseOtherwise.

◆ tetengo_lattice_constraint_matchesTail()

bool tetengo_lattice_constraint_matchesTail ( const tetengo_lattice_constraint_t *  p_constraint,
const tetengo_lattice_node_t p_reverse_tail_path,
size_t  tail_path_length 
)

Returns true when the tail path matches the tail of the pattern.

Parameters
p_constraintA pointer to a constraint.
p_reverse_tail_pathA poiner to a tail path in reverse order.
tail_path_lengthA tail path length.
Return values
trueWhen the tail path matches the tail of the pattern.
falseOtherwise.