Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement a visitor function #23

Closed
abdullahemad12 opened this issue Jan 6, 2019 · 0 comments
Closed

implement a visitor function #23

abdullahemad12 opened this issue Jan 6, 2019 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@abdullahemad12
Copy link
Owner

abdullahemad12 commented Jan 6, 2019

Task

implement cbt_visit_all() function that takes a pointer to a function and call this function on all the objects in all the nodes of the tree.

Method

The function will traverse the whole tree starting from the root until it reaches all the leaves and will call the visitor function on all the objects saves in the nodes of the tree.

Prototype

/**
  * crabtree_t* , void (*) (void *)  -> void
  * EFFECTS: Calls the visitor function on every object pointer stored in the tree
  * MODIFIES: cranbtree.objects
  * REQUIRES: The  visitor function to take a void* as an argument and to return nothing 
  * PARAMETERS: 
  * - cranbtree_t* cbt: the tree to be traversed
  * - void (* visitor) (void *): the function that will be invoked on every object in the tree  
  */
void cbt_visit_all(cranbtree_t* cbt, void (* visitor) (void *))

Where to code

  • the interface function will go to src/cranbtree.c
  • any helpers will go to src/lib/visit.c

Tests

  1. Test the visit function on an empty tree Error reporting in cbt_visit_all #24
  2. Test the visit function on a tree with a NULL visitor pointer Error reporting in cbt_visit_all #24
  3. Test the visit function on an a large tree
@abdullahemad12 abdullahemad12 self-assigned this Jan 6, 2019
@abdullahemad12 abdullahemad12 added the enhancement New feature or request label Jan 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant