GenericTree - Generic tree structure module
[Lexical tools level]

Definition and handling of generic tree data structure (former arbregen module). More...

Data Structures

struct  TreeSpecies
 Tree species. More...

Typedefs

typedef unsigned long TreeMemPos
 Tree node index.
typedef unsigned char TreeNode
 Tree node.
typedef TreeNodeTree
 Tree data structure.

Enumerations

enum  TreeFormat { COMPRESSED_TREE, GROWING_TREE }
 Tree format. More...

Functions

void treeExplore (const Tree *tree, const TreeSpecies *species, LongStack *node_stack)
void treeDump (const Tree *tree, const TreeSpecies *species, int(*print_function)(const char *,...))
TreeMemPos treeNodeGetNextSiblingOffset (const TreeNode *node, const TreeSpecies *useless)
TreeMemPos treeNodeGetNextChildOffset (const TreeNode *node, const TreeSpecies *useless)
Tree treeCreate (TreeSpecies *species)
void treeFree (Tree *tree, TreeSpecies *species)
TreeMemPos treeAddSibling (Tree *main_tree, TreeSpecies *species, const TreeMemPos sibling_index, const Tree *sub_tree, const size_t sub_tree_size)
TreeMemPos treeNodeDecodeSiblingOffset (const TreeNode *node)
void treeNodeCodeSiblingOffset (TreeNode *node, const TreeMemPos sibling_offset)
int treeSave (const Tree *tree, const TreeSpecies *species, const char *filename)
int treeSaveFile (const Tree *tree, const TreeSpecies *species, FILE *file)
int treeLoad (Tree *tree, TreeSpecies *species, const char *filename)
int treeLoadFile (Tree *tree, TreeSpecies *species, FILE *file)
TreeMemPos treeNodeCodeULong (TreeNode *node, const unsigned long value_to_code, const unsigned char mask)
unsigned long treeNodeDecodeULong (const TreeNode *node)
char treeNodeDecodeChar (const TreeNode *node)

Detailed Description

Definition and handling of generic tree data structure (former arbregen module).

SlpTK Library 0.6.0

Required header
<generictree.h>
Author:
Jean-Cédric Chappelier (creation on 20.12.1996)

Antonin Merçay (revision on 23.11.2004)

Date:
2 March 2005
Version:
0.6.0

Typedef Documentation

typedef TreeNode* Tree

Tree data structure.

A tree is formally an array of (tree) nodes

See also:
TreeNode

typedef unsigned long TreeMemPos

Tree node index.

Specify the tree index of a given tree node (allows 32 bits addressing)

See also:
Tree TreeNode

typedef unsigned char TreeNode

Tree node.

Basic unit of a tree

See also:
Tree


Enumeration Type Documentation

enum TreeFormat

Tree format.

Specify the internal format of the tree

Enumerator:
COMPRESSED_TREE  The tree is compressed
GROWING_TREE  The tree is in building process


Function Documentation

TreeMemPos treeAddSibling ( Tree main_tree,
TreeSpecies species,
const TreeMemPos  sibling_index,
const Tree sub_tree,
const size_t  sub_tree_size 
)

Insert a ?FILAIRE? subtree as a sibling of a tree node

Parameters:
main_tree The tree where to add
species The species of the tree
sibling_index The tree node index of the sibling to add
sub_tree The copy of the sub tree to add
sub_tree_size The size of the sub tree to add
Returns:
The index of the added sibling
Remarks:
il n'y a pas de test d'erreur si l'arbre est compresse ou non car afin de ne pas ralentir cette fonction appellee tres souvent. Il faut toujours faire le test avant son appel
Former(s) function(s):
Greffe_Frere

Tree treeCreate ( TreeSpecies species  ) 

Create a new tree of a given species

Parameters:
[in] species The species of the tree to create
Returns:
The created tree
See also:
treeFree()
Former(s) function(s):
Alloue_Arbre

void treeDump ( const Tree tree,
const TreeSpecies species,
int(*)(const char *,...)  print_function 
)

Dump the contents of a tree using bracketed format

Parameters:
[in] tree The tree to explore
[in] species The tree species
[in] print_function The print function to use
Former(s) function(s):
Affiche_Arbre_Simple

void treeExplore ( const Tree tree,
const TreeSpecies species,
LongStack node_stack 
)

Perform a depth-first traversal step of a growing tree

Parameters:
[in] tree The tree to explore
[in] species The tree species
[out] node_stack A stack where to store the tree node index
Former(s) function(s):
Parcours_Arbre_Simple

void treeFree ( Tree tree,
TreeSpecies species 
)

Free the memory allocated to a tree

Parameters:
[in] tree The tree
[in] species The species of the tree
See also:
treeCreate()
Former(s) function(s):
Libere_Arbre

int treeLoad ( Tree tree,
TreeSpecies species,
const char *  filename 
)

Load a tree and its species from a binary file

Parameters:
[out] tree The tree to load
[out] species The species of the tree
[in] filename The name of the input file
Returns:
An error code
See also:
treeSave() treeLoadFile()
Former(s) function(s):
Read_Arbre

int treeLoadFile ( Tree tree,
TreeSpecies species,
FILE *  file 
)

Load a tree and its species directly from a binary file

Parameters:
tree The tree where to load
species The species of the tree
file The source binary file
Returns:
A not null error code if operation fails
See also:
treeSaveFile() treeLoad()
Former(s) function(s):
Fichier_Read_Arbre

void treeNodeCodeSiblingOffset ( TreeNode node,
const TreeMemPos  sibling_offset 
)

Code the offset to a sibling from a tree node

Parameters:
[in] node The tree node address where to code
[in] sibling_offset The offset to the sibling value
See also:
treeNodeDecodeSiblingOffset()
Former(s) function(s):
Put_Dep_Frere

TreeMemPos treeNodeCodeULong ( TreeNode node,
const unsigned long  value_to_code,
const unsigned char  mask 
)

Code (with overflow bit) an unsigned long value in a node

Parameters:
[in] node The address where to start the coding
[in] value_to_code The value to code
[in] mask ?
Returns:
The coding size ?
See also:
treeNodeDecodeULong()
Former(s) function(s):
Code_Ulong_BdD

char treeNodeDecodeChar ( const TreeNode node  ) 

Return the char value coded (with overflow bit) in a node

Parameters:
[in] node The address of the node to decode
Returns:
The coded value
Former(s) function(s):
Decode_Char (former arbrelex module)

TreeMemPos treeNodeDecodeSiblingOffset ( const TreeNode node  ) 

Decode the offset to a sibling from a tree node

Parameters:
[in] node The tree node address to decode
Returns:
The offset (always greater than 0) to the sibling
See also:
treeNodeCodeSiblingOffset()
Former(s) function(s):
Get_Dep_Frere

unsigned long treeNodeDecodeULong ( const TreeNode node  ) 

Return the unsigned long value coded (with overflow bit) in a node

Parameters:
[in] node The address of the node to decode
Returns:
The coded value
See also:
treeNodeCodeULong()
Former(s) function(s):
Decode_Ulong_BdD

TreeMemPos treeNodeGetNextChildOffset ( const TreeNode node,
const TreeSpecies useless 
)

Return the address offset to the next node (the child initially) of a growing tree node

Parameters:
[in] node The address of the node to treat
useless Parameter not used
Returns:
The address offset
See also:
treeNodeGetNextSiblingOffset()
Former(s) function(s):
Next_Noeud_Simple

TreeMemPos treeNodeGetNextSiblingOffset ( const TreeNode node,
const TreeSpecies useless 
)

Return the address offset to the next sibling of a growing tree node

Parameters:
[in] node The address of the node to treat
useless Parameter not used
Returns:
The address offset
See also:
treeNodeGetNextChildOffset()
Former(s) function(s):
Next_Frere_Simple

int treeSave ( const Tree tree,
const TreeSpecies species,
const char *  filename 
)

Save a tree and its species in a binary file

Parameters:
[in] tree The tree to save
[in] species The species of the tree
[in] filename The name of the output file
Returns:
An error code
See also:
treeLoad() treeSaveFile()
Former(s) function(s):
Write_Arbre

int treeSaveFile ( const Tree tree,
const TreeSpecies species,
FILE *  file 
)

Save a tree and its species directly in a binary file

Parameters:
tree The tree to write in file
species The species of the tree
file The file where to write
Returns:
A not null error code if operation fails
See also:
treeLoadFile() treeSave()
Former(s) function(s):
Fichier_Write_Arbre


Generated on Thu Mar 22 17:46:31 2007 for SlpTk by  doxygen 1.4.7